Example emit

Emit an event to a room in a collection. A successful emit request will respond with OK (17)


[scope, room_id, event, ...args]

The args are optional argument to send with the event.

The socket needs to be authorized before sending a emit request. See the auth example for how to authorize a socket connection.


As an example we assume that we have a room with Id 17 in collection stuff.

This is the data we want to pack (emit event “new-message” to room Id 17 with one argument “Hello!"):

["//stuff", 17, "new-message", "Hello!"]

Serializing the above using MessagePack results in the following 29 bytes:


Now we create the header. For this example we just use Id 0:

  • Data length (29) \x1d\x00\x00\x00
  • Identifier (0) \x00\x00
  • Request Emit package type (40) \x28
  • Inverse type check bit (247) 0xd7

Sending the Emit package


Responding OK package