A named group of connections that can be addressed as one.
Creates a room.
listener: RoomMembershipListener
Notified on every membership change. Supplied by a
RoomRegistry; omit for a standalone room.
publish: RoomPublisher
Forwards broadcasts to other replicas. Omit for a room that stays in-process.
add(conn: IWebSocketConnection): void
Adds a connection to this room.
broadcast(data: string | Uint8Array,options?: RoomBroadcastOptions): void
Sends a frame to every open member, skipping any closed member and any
member named by options.except.
broadcastJson<T>(payload: T,options?: RoomBroadcastOptions): void
Serializes a value to JSON once and broadcasts it as a text frame.
broadcastLocal(data: string | Uint8Array,options?: LocalBroadcastOptions): void
Sends a frame to this replica's own members only, without forwarding it to the backplane.
This is the delivery path for a frame that ARRIVED from another replica:
re-publishing it would echo it back around the cluster forever. Applications
call Room.broadcast; only the plugin's backplane subscriber
calls this.
Exclusion is honored two ways: options.except names a live connection
object (the local path), and options.exceptId names one by ID (the path a
frame arriving from another replica takes, since the excluded connection
object does not exist here).
remove(conn: IWebSocketConnection): void
Removes a connection from this room.