Channelstream

Friendly and scalable websocket server for applications

Example message API calls

Send a message to all users listening on specific channel

This will broadcast a message to all connections listening on this channel, from_user does NOT have to be an existing connected user, it will inform listening clients about what entity sent the message.

    [{
      "channel": "tutorial/messaging",
      "user": "from_user",
      "message": {"text": "My message text", "can":"store_different_keys", "counter": 5}
    }]
    

Send a message to some users listening on specific channel

This will broadcast a message to some connections listening on this channel, You can also exclude users from the broadcast, for example, you might not want to message sender itself, or filter based on user permissions in your application.

    [{
      "channel": "tutorial/messaging",
      "user": "from_user",
      "pm_users": ["messaging-demo-user", "some-other-user"],
      "exclude_users": [
        "exclude-this-user", "random-user"
      ],
      "message": {"text": "My message text"}
    }]

Send a message globally to specific user

This will broadcast a message to all user connections regardless of their channel subscriptions.

[{
  "user": "from_user",
  "pm_users": ["messaging-demo-user", "some-other-user"],
  "message": {"text": "My message text"}
}]

Send a message to a channel and do not save it in history

    [{
      "channel": "tutorial/messaging",
      "user": "system",
      "no_history": true,
      "message": {"text": "My message text"}
    }]
    

Modify message already sent to channel

This API call will emit message:edit message type and will also rewrite channel's history. To test this copy paste UUID of the message returned by the response for the first example. It is important to send same channel/pm_users/exclude keys in the edit message if you want to notify same connections as in original message.

    [{
      "channel": "tutorial/messaging",
      "uuid": "USE_UUID_FROM_FIRST_EXAMPLE",
      "user": "my_new_user",
      "message": {"text": "My new payload"}
    }]

Delete message already sent to channel

This API call will emit message:delete message type and will also rewrite channel's history. To test this copy paste UUID of the message returned by the response for the first example. Remember to send channel/pm_users/exclude keys where applicable.

    [{
      "channel": "tutorial/messaging",
      "uuid": "USE_UUID_FROM_FIRST_EXAMPLE"
    }]