Room Lifecycle
Rooms are created via the REST API and cannot be created from the client SDK. The typical flow is:-
Your backend creates a room via
POST /rooms -
Your backend adds a user via
POST /users, gets a JWT token -
The client SDK connects and joins the room using the JWT token
-
The room tracks participants, presence, and all collaboration state
After connecting and joining, room information is available using:
You can also fetch the current room’s details from the server:This method also returns a list of users in the room
Connection Lifecycle
The client exposes low-level connection events viaclient.socket. Use these to monitor connection state, handle disconnections, and implement custom reconnection logic like so:
Lifecycle Events
| Event | Payload | Description |
|---|---|---|
connected | none | Initial WebSocket connection established and authenticated |
disconnected | none | WebSocket connection closed |
reconnecting | { attempt: number } | A reconnection attempt is starting |
reconnected | none | Successfully reconnected and state has been rehydrated |
failed | none | All reconnection attempts have been exhausted |
authFailed | none | The JWT token was rejected by the server |
Auto-Reconnection
The SDK automatically reconnects when the WebSocket connection drops unexpectedly. It uses exponential backoff with configurable parameters:- Reconnection starts immediately after disconnection
- Each subsequent attempt waits longer (exponential backoff)
- After all attempts are exhausted, the
failedevent fires