Skip to content

List of messages exchanged

nckswt edited this page Nov 12, 2013 · 6 revisions

Cortex uses socket.io as the underlying messaging protocol. As such, it uses some of socket.io's exposed message events, and builds on top of them some additional abstractions:

  • Broadcast: used to broadcast some data related to a specific topic. The callback functions gets a message parameter as follows: message:{ topic : String, data : String }

  • Set Username: used to communicate to the server the username chosen by the client. The client must wait for the server to confirm that the username is valid. The callback functions gets a message parameter as follows: message:{ username: String }

  • Confirm Username: used to communicate to the client that the username chosen by the client is valid, and can be used for future communication. The callback functions gets a message parameter as follows: message:{ username: String }

  • User Joined: used to broadcast to all connected clients that a new client has joined. The callback functions gets a message parameter as follows: message:{ username: String }

  • User Left: used to communicate to the server the username chosen by the client. The client must wait for the server to confirm that the username is valid. The callback functions gets a message parameter as follows: message:{ username: String }

  • Register: used to communicate to the server the list of topics that the client wishes to listen to. Note that the client won't receive any message until he had registered to at least one topic. The callback functions gets a message parameter as follows: message:{ topics: [String] }

If topics = ['*'], then the client is subscribed to all the topics.

  • Poll: used to read data from an arbitrary sensor. Sensor must be specified as a parameter. The callback functions gets a sensor parameter as follows: message:{ topic : String, data : String }

  • Unregister: used to communicate to the server the list of topics that the client wishes to stop listening to. Note that the client will continue receiving messages until he unregistered to all of the topics he has previously registered to. The callback functions gets a message parameter as follows: message:{ topics : [String] }

If topics = ['*'], then the client is unsubscribed from all the topics.

Clone this wiki locally