Sending messages

How did we do?

When you want to send messages from a connected HiveMP Chat WebSocket, you'll need to create or get a chat group to send messages to.

Creating a chat group

To send messages to another user, or to a group of users, you first need to create or get a chat group that has those users as members by sending a cg (createGroup) message:

{
  "type": "cg",
  "value": {
    "ids": [
      "YOUR_ACCOUNT_ID",
      "FRIEND_ACCOUNT_ID"
    ]
  }
}

You'll receive a gi (getGroupInfo) message soon after making the request, which will contain the id of the group to use as the rid when sending messages to the group:

{
  "type": "gi",
  "value": {
    "id": "cg-5682741632827394",
    "ids": [
      "YOUR_ACCOUNT_ID",
      "FRIEND_ACCOUNT_ID"
    ],
    "t": "Group Title"
  }
}

Sending a message

Once you have the chat group information, you can then send a message to the group with the mi (sendMessage) request. Use the chat group ID as the rid field value. The sts field should be the current UTC UNIX timestamp.

{
  "type": "mi",
  "value": {
    "msg": "This is my message.",
    "rid": "cg-5682741632827394",
    "sts": 1534754271
  }
}