Example leave

Leave one- or more joined rooms. A successful leave request will respond with an array of equal length of the number of rooms.


[scope, ...IDs]

The IDs are the room-IDs you want to leave.

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


As an example we assume that we want to leave a joined room with Id 17. Instead of a single ID, we could add as much IDs as we wanted. As an example we also add room Id 456 which does not exist in our collection.

This is the data we want to pack (leave room Ids 17 (exists in out collection) and 456 (does not exist)):

["//stuff", 17, 456]

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


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

  • Data length (13) \x0d\x00\x00\x00
  • Identifier (0) \x00\x00
  • Request Leave package type (39) \x27
  • Inverse type check bit (249) 0xd9

Sending the Join package


Responding [17, nil] package (room Id 17 is found, the second (456) was not)


A few seconds (or less) later, you will receive a on-leave event on the socket connection for every room.

See the listening documentation for more information.

Responding {id: 17} package for room 17 which was joined in our example: