Learn · Room model
Rooms
Room identity, shared history, current state, and lifecycle.
A room is the durable workspace for one product session. Participants share its history and current state while seeing only the records their authority allows. A support conversation with a customer, specialist, and assistant is one example.
Choose the shared boundary
Put related channels, participants, state, and work in the same room when they need one ordered history. Every committed event receives a room-wide seq. Channels in that room share the sequence space; separate rooms have independent histories and authority.
The product chooses the room's lifetime. A component unmount, WebSocket reconnect, or media disconnect does not create a new business session by itself. Keep the room ID in your application session so returning clients can rejoin the same workspace.
Create on the backend, join from the client
// Trusted backend; client is an RmcClient, serverAdminToken is server-owned.
const created = await client.createRoom("support", serverAdminToken);
const owner = client.room(created.room.id, created.token);
Create rooms on your backend, then invite scoped participants for clients. Keep the owner credential on the backend; it has broad authority over the room.
Recover the right information
room.snapshot() returns authorized current projections: channel definitions, state documents, artifacts, conversation turns, and delegations. Use it to hydrate those resources. A custom chat feed still needs its own saved projection or event replay; snapshots do not contain every application event.
Use the hydration recipe to combine a snapshot with subsequent updates without applying older versions twice.
Distinguish local disposal from remote closure
room.dispose() releases this client's subscriptions and stream. await room.closeRoom() closes the shared room remotely and then disposes the handle after a successful response. Closing a room affects other participants and requires room:close on the room ID. Native voice and media resources have their own cleanup.
Follow the implementation through RoomSession, room storage, and RoomClient. Continue with participants and channels.