Websocket Connection for Receiving Live Messages: /ws (WEBSOCKET)

Purpose:

This WebSocket endpoint is specifically designed to establish a WebSocket connection that allows users to receive messages in real-time. It does not handle sending messages. NOTE: USE ws:// INSTEAD OF http://

Input:

  • Query Parameters:
    • token: The JWT token of the user.

Output (200):

"Websocket Connection Established"

Additional Information:

Example of a received message from the websocket:

{
  "id": "da032ee6-bad0-4f08-9841-01480e493051",
  "user_id": "20424c2e-1cf9-4345-81c0-4aaa59d876a2",
  "content": "hello",
  "date_created": "2024-09-09 14:06:11.251848",
  "date_updated": "2024-09-09 14:26:57.768097138",
  "message_type": "MESSAGE",
  "recipient_type": "CHANNEL",
  "reference_id": "c8132499-8e78-47fd-ada4-c4e259d5fc01",
  "deleted": false
}

Example of an editted message from the websocket:

{
  "id": "da032ee6-bad0-4f08-9841-01480e493051",
  "user_id": "20424c2e-1cf9-4345-81c0-4aaa59d876a2",
  "content": "hello",
  "date_created": "2024-09-09 14:06:11.251848",
  "date_updated": "2024-09-09 14:26:57.768097138",
  "message_type": "EDIT_MESSAGE",
  "recipient_type": "CHANNEL",
  "reference_id": "c8132499-8e78-47fd-ada4-c4e259d5fc01",
  "deleted": false
}

Example of a deleted message from the websocket:

{
  "id": "da032ee6-bad0-4f08-9841-01480e493051",
  "user_id": "20424c2e-1cf9-4345-81c0-4aaa59d876a2",
  "content": "hello",
  "date_created": "2024-09-09 14:06:11.251848",
  "date_updated": "2024-09-09 14:26:57.768097138",
  "message_type": "DELETE_MESSAGE",
  "recipient_type": "CHANNEL",
  "reference_id": "20e15fcf-484c-4d67-859f-f692f0a50eaf",
  "deleted": true
}

Example of a typing indicator from the websocket:

{
  "message_type": "TYPING",
  "recipient_type": "CHANNEL",
  "reference_id": "aa09131f-bc17-4c24-8a6c-e3eb4e868b34",
  "user_id": "b5725c67-d2de-43c0-aa38-81e7e8339f42"
}

Example of the UPDATE_STATUS message type which is used to signify that we should refresh users, roles, channels, and presences:

{
  "message_type": "UPDATE_STATUS"
}

Example of the UPDATE_USERS message type which is used similarly to UPDATE_STATUS, but primarily to update users and presences:

{
  "message_type": "UPDATE_USERS"
}