Skip to main content
Version: 5.7.0

Chat

Chat is a new service that enables real-time communication between end-users. It is available to apps that have brainCloud RTT enabled.

Key concepts

  • Chat messages are directed to channels, not users
  • Channels have two important relationships with users:
    • members (subscribers) -- persistent members of the channel. i.e. those who can access messages, and are allowed to listen to real-time chat
    • listeners -- online members who are listening right now! Chat messages are "pushed" only to active listeners
  • There are different types of channels. Channel types determine by how members and listeners are managed. See Channel Types section below.
  • A rolling history of chat messages is maintained per channel
  • Chat messages are simple json objects (see format below)
  • There are both member and system chat messages
    • Member chat messages are from an end-user who is a member of the channel. Member messages have the user's profileId in the fromId field
    • System chat messages are from the system (i.e. the app or game) itself. Those message will have null in the fromId field
  • Every chat message is assigned an id. The message id (msgId) must be combined with the channel id (chId) to fully reference the message

Chat message format

{
"chId": "<channel id>",
"msgId": "<guid>",
"date": 1530069895070,
"ver": 1,
"from": {
"id": "<profileId>",
"name": "<name>",
"pic": "<pictureUrl>"
},
"content": {
"text": "simple message",
"rich": {}
}
}

Chat message fields

FieldDescription
chIdThe channel id
msgIdThe chat message id (used for editing / deleting posted messages)
dateThe time the message was posted (in utc millis)
verThe version of the message
fromInformation about who the chat message is from. Includes name and picture url if available
contentThe content of the chat message. Contents are up to the developer - but for visibility in tools, should have a text field for plain-text message content

Channel Types

brainCloud currently supports four types of channels:

Channel TypeMembershipCreationDescription
globalAll users of the appVia portalAll users of an app can access global channels. By default, an app can have up to 10 channels. Contact us with your use case for more. The global channel id is formed as appId:gl:channelCode.
groupAll members of a GroupAutoA channel is automatically created for each group in the system. Any group member can access it. The group channel id is formed as appId:gr:groupId.
dynamicAll users of the appAutoDynamic chat channels are special channels that any user can create and/or join. They exist only for as long as there is activity. Once the channel inactivity timeout expires (typically 30 days), the history (and the channel itself) are automatically deleted and cleaned up. The dynamic channel id is formed as appId:dy:channelCode.
systemUse for s2s system channelAutoA channel is designed for s2s connenction. The system channel id is formed as appId:sy:channelCode.

Pro-tip - if you are interested in one-to-one chat, see our Messaging api...

API Summary

Channel lookup and management

Retrieving chat messages

Posting chat messages

Updating chat messages

System chat API (cloud-code only)

These API calls bypass channel membership / message ownership checks - and allow you to post messages from the system (i.e. app) instead of from another end-user: