Wikis > Lobby


The lobby service provides a means for users to join a virtual group using a pre-agreed lobby name. It is the on-boarding mechanism used to group multiple layout contexts together for synchronised playback and is used as a filter for real-time communication between different groups of users.


Client – is an instance of the 2Immerse application. In general, there is one client running per device, but a web browser could be running multiple instance of the application in different tabs.

Layout context – is a temporary collection of clients on the same LAN that are collaborating to present one multi-device broadcast.

User – is a person who has signed into a client. A user can be signed into multiple clients simultaneously.

Host – is a user who launches a programme and therefore owns the layout context.

Lobby – is a set of layout contexts that are watching a synchronised programme together.


The lobby service displays a table of users grouped by layout context.




The challenge is to ensure the table accurately reflects user presence at all times. A user is considered present if a device they are signed into is in regular contact* with the lobby service.

* Regular contact can be achieved using a heartbeat mechanism over a stateless connection (e.g. long poll) or inferred by monitoring a permanent socket connection. Socket.io is a node.js library that abstracts away the mechanism used.

Each device in the layout context must therefore be instructed to declare and update its presence with the lobby server and must be capable of displaying the lobby table (DMApp component) if instructed to by the layout context. These requirements demand that a lobby client component be instantiated on each device in the layout context.

A lobby member is uniquely identified by a (layoutContextId, userId) pair. This is because a user could be signed into several clients with their credentials and those clients could be used in different layout contexts.


Synchronisation between layout contexts is brokered by the lobby service but it requires one user from each layout context to instigate a ‘Join Lobby’ operation. This must pull other members of the layout context into the lobby automatically. There are two possible schemes:

  1. The ‘Join Lobby’ operation broadcasts a message to all other devices in the layout context asking them to connect to a specified lobby.
  2. The layout context joins the lobby, submitting and updating user presence information on behalf of members of the layout context.

In the first approach, the lobby service is duplicating some of the presence tracking done by the layout context. In the second approach, where the layout service is acting as a proxy, the layout service is taking on additional responsibilities that prevent a clear separation of concerns. An alternative to both approaches is to separate out user presence management into a separate service which the lobby and layout services can depend upon. This could also act as a proxy for the call service, keeping it informed of contactable video-chat enabled peers.


The lobby service is multi-tenant, allowing many lobbies to be hosted by a single service instance. Lobby membership information is distributed between lobby server instances as opposed to being persisted to a database. Horizontal scaling of lobby service instances is triggered when memory or network connection limits exceed a pre-defined threshold or latencies increase to a level that delivers a poor user experience.

A lobby doesn’t exist prior to the first user joining and ceases to exist after the last user has left. Users can join and leave the lobby at any time and all members are notified of these events.

Each client establishes a single secure web socket with one of the lobby service instances, either directly or through a presence service. The connection is used to track the client and to notify them of lobby events. It allows the client to subscribe to user leave/join/message notifications from the server and allows the server to detect disconnections.

Clients making a lobby service request directly or indirectly via a presence service must provide a valid session access token in order to use the lobby service API. The token can be sent to the server via a cookie for both REST and web socket communications. The lobby service validates the access token and requests the session’s userId from the session service. Users are internally identified to the lobby service by their unique userId (which is the same as the call service’s caller Id).

On joining a lobby, a client is issued with a list of existing lobby members. Clients can track changes to lobby membership by processing leave and join notifications from the server. An administrator can connect to the lobby service for the purpose of moderation without joining a lobby.

The lobby service subscribes to the session events, such as session expiration, session invalidation and user sign-out. It uses these events to automatically evict users from the lobby and drop their connections.

A client wishing to create a new lobby can request a unique lobbyId from the lobby service. The lobbyId is a memorable, human readable string that can be shared by individuals via conventional channels of communication such as over the phone or by embedding it in a URL. It is the key piece of information used to group participants for synchronised media playback between layout contexts. A commonly used scheme is a hyphen separated list of 3-4 of the most commonly used English language nouns.

The lobby service can broadcast application-defined messages on behalf of a user to all other users in the lobby and their signed-in clients. This is useful for signalling changes in the state of a shared experience and to synchronise actions between peers without having to establish separate peer-to-peer connections. An example would be an application-defined message instructing each client to begin playing a media stream.


  • Provide a framework for group activities involving a number of users.
  • Maintain lobby connections and manage user membership
  • Share membership information with clients
  • Generate lobby events on the micro service message bus for subscribers to listen to.
  • Notify clients of join and leave events
  • Generate unique lobbyIds
  • Provide administration and chair functions.


Lobbies provide a means of establishing video and voice chat between groups and users by making their callerIds (userIds) available to other members of the lobby. The call service uses these callerIds to broker connections between peers so that they can execute the session initiation protocols required for real-time video chat. It is then the call service’s responsibility to resolve which client device to forward the offer to.

Text chat is different to video and voice chat because conversation history must be preserved and unlike video chat, it is unlikely to require a dedicate device. There are two use cases:

  1. Communal text chat – everyone in the lobby can see the conversation
  2. One-on-one chat – a user wishes to have a private chat with one of the other lobby members.

It is likely that a separate service will be used to manage the lobby’s communal chat history and to broadcast text messages to lobby members. Any client can render a view of chat history and add new messages. This doesn’t require an offer/answer signalling mechanism; all clients participate. One-on-one chat may still be handled by a separate chat service, but will use offer/answer semantics via the call service to establish communication.



A lobby server is responsible for running the core business logic and for maintaining persistent web socket connections with clients or a separate presence server. The number of server instances can be scaled up and down to meet demand. Clients within the same layout context could therefore be connected to different lobby servers and their connections may be lost if servers are taken offline, requiring the client to reconnect.

A load balancer will distribute web socket connections to different server instances to spread the load and then use the publish/subscribe machinery of RabbitMQ, Redis or ZeroMQ to route messages between the server instances. Each server will maintain a list of connected clients grouped by lobbyId and will use routing keys to keep the number of messages between servers to a minimum.


Lobby membership and connectivity is shared between lobby server instances without the need for a database. Lobby server instances communicate with each other to keep themselves up-to-date using message queues and routing exchanges. A publisher/subscriber model is used in conjunction with routing keys and RPCs to send lobby events to the right server instances.

Changes to lobby membership are published as messages and routed to other server instances. Messages destined for the members of a lobby can be filtered using routing keys. This causes them to be routed to only those server instances responsible for managing connections to other members of the lobby. Servers that manage client connections for a given lobby can subscribe to the message queue using the lobby’s routing key. When combined with a limit on lobby occupancy, the number of server-to-server messages can be kept to a minimum, permitting good scalability.


An alternative scheme is to use a database to manage lobby membership and allow new servers to be provisioned in the event of scaling or failover, but this also requires a garbage collection service to ensure old lobbies and users are removed from the database on client disconnect or server failure. The benefit of using websocket / persistent connections is that garbage collection is implicit and so the record of lobby membership cannot become out of date with respect to the list of server connections.


  • Logging service
  • Session service
  • User Identity service
  • Call service
  • Layout service




ssoToken: session access token


Unique lobbyId


Generates a unique, human readable lobbyId.


Join(ssoToken, lobbyId)


ssoToken: session access token

lobbyId: identifier or name of the lobby to join


members: a list of lobby members


Adds the user specified by the session access token to the specified lobby and broadcasts a ‘joined’ notification event to each connected client. This method has no effect if the user is already a member of the specified lobby. A list of lobby members is returned in the response. If the lobby is full, the user will not be added to the lobby and an error response is returned.


Leave(ssoToken, lobbyId)


ssoToken: session access token

lobbyId: identifier or name of the lobby to leave


Removes the user identified by the session access token from the specified lobby and broadcasts a ‘left’ notification event to each connected client. This method has no effect if user has already left the lobby.


BroadcastMessage(ssoToken, lobbyId, message)


ssoToken: session access token

lobbyId: identifier or name of the lobby to broadcast to

message: application defined message payload


Broadcast an application-defined message to all connected clients. This is intended to allow application specific functionality to be layered on top of the lobby whilst keeping the lobby service as simple as possible.


Close(ssoToken, lobbyId)


ssoToken: session access token

lobbyId: identifier or name of the lobby to leave


Close a lobby and notify all connected clients by sending a ‘disconnect’ message. This is an administrative function intended for use by a chair or system administrator.


Kick(ssoToken, lobbyId, userId)


ssoToken: session access token

lobbyId: identifier or name of the lobby to leave

userId: the user to evict


Evicts a user from a lobby and sends a ‘disconnect’ message to all clients of the user. Also notifies remaining clients by sending a ‘leave’ notification. This is an administrative function used for moderation purposes and is intended for system administrators.


GetMembers(ssoToken, lobbyId)


ssoToken: session access token

lobbyId: identifier or name of the lobby


Retrieve a list of lobby members.




An administrator or chair has disconnected the client’s connection with the lobby.


A user has joined the lobby.

Payload: userId indicating the user that has joined the lobby.


A user has left the lobby.

Payload: userId indicating the user that has left the lobby, either explicitly, as a result of a loss of connection with the lobby service or as a result of being evicted from the lobby by a chair or administrator.


A user has broadcast a message

Payload: (userId, message) indicating the user that issues the message and the message itself.


This event is received in response to a failed connection attempt such as an authentication failure or the lobby being full.

Payload: (error code) indicating type of error

Recent Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search