WebSocket Message Types¶
When your client is connected to the GroupMe WebSocket server and subscribed to channels, you will receive messages. These messages follow the Bayeux protocol, and the core information is typically found within the data
object of the incoming Faye message.
The most important field within the message object is data.type
, which indicates the kind of event that has occurred.
The following sections describe the different message types you may receive, along with their data structure and properties.
ping
¶
A keep-alive heartbeat message. This message is sent down every 30 seconds in order to ensure your client is still listening. You can generally ignore these messages if you dont plan on sending them, as the server will keep the connection alive on its own. Sending a ping
type message causes the server to echo one back and then supresses the server from sending pings for the next 30 seconds. By timing how long it takes to send this message and then receive an echoed ping from the server you can effectively calculate roundtrip ping latancy for the WebSocket gateway.
This and typing
are the only two message types clients are permitted by the API to send.
- type
string - Must be ping
.
line.create
¶
A message was sent in a channel you participate in. This is the most common type of message, and includes many events that normally send system messages (like member join/leave events). More on events can be found here.
Generally, incoming messages will look like this:
- type
string - Must be line.create
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - The message object this push is refering to.
- received_at
number - the timestamp corresponding to when the notification was sent.
However, in some cases you may observe a system message with an attached subject.event
property. These events are documented here.
- type
string - Must be line.create
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - The message object this push is refering to.
- received_at
number - the timestamp corresponding to when the notification was sent.
direct_message.create
¶
line.create
, but for received DMs.
Generally, incoming messages will look like this:
- type
string - Must be direct_message.create
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - The message object this push is refering to.
- received_at
number - the timestamp corresponding to when the notification was sent.
However, in some cases you may observe a system message with an attached subject.event
property. These are documented here.
- type
string - Must be line.create
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - The message object this push is refering to.
- received_at
number - the timestamp corresponding to when the notification was sent.
membership.create
¶
Fired when you're added to a group.
- type
string - Must be membership.create
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - A cut down group object describing the group that you've joined.
- received_at
number - the timestamp corresponding to when the notification was sent.
favorite
¶
Someone reacted to a message. This message is also sent when someone removes a reaction from a message.
- type
string - Must be favorite
.
- alert
string - The text that would usually populate the push notification preview. In this case, there is no text, so alert
will always be an empty string.
- subject.line
object - The message being reacted to.
- subject.reactions
array - A list of reaction objects currently tied to the message.
- received_at
number - the timestamp corresponding to when the notification was sent.
message.deleted
¶
A message was deleted. This type is limited to group or direct message channels where the deletion was observed, however it is always paired with a corresponding line.create
message containing a message.deleted
message event that can be caught from the main user channel.
- type
string - Must be message.deleted
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - The message object that needs to be deleted.
- received_at
number - the timestamp corresponding to when the notification was sent.
message.update
¶
A message was edited. This type is limited to group or direct message channels where the edit was observed, however it is always paired with a corresponding line.create
message containing a message.update
message event that can be caught from the main user channel.
- type
string - Must be message.update
.
- alert
string - The text that would usually populate the push notification preview.
- subject
object - The new message object that should replace the existing message.
- received_at
number - the timestamp corresponding to when the notification was sent.
typing
¶
Someone started typing. This type is limited to group or direct message channels where the typing indicator was observed. GroupMe will send these indicators every 5 seconds while typing. Clients assume typing has stopped if there is no new typing message after 5 seconds, or the user who is typing sends a message before the 5 seconds is up.
This and ping
are the only two messages clients are allowed to send.
- type
string - Must be typing
.
- user_id
string - The ID of the user who is typing.
- started
number - A timestamp corresponding to when the typing started.