Skip to content

Documentation / @super-line/server / Room

Interface: Room<C>

Defined in: index.ts:198

A mixed-role, server-controlled connection group. broadcast delivers a shared event to every member, regardless of their role.

Type Parameters

C

C extends Contract

Properties

connections

readonly connections: Conn<Record<string, ServerMessageDef>, unknown, string, unknown, unknown>[]

Defined in: index.ts:215

Snapshot of this room's members on the current node.


size

readonly size: number

Defined in: index.ts:213

Member count on the current node (membership is node-local).

Methods

add()

add(conn): void | Promise<void>

Defined in: index.ts:207

Add a connection to the room (server-controlled membership).

Returns a promise when this is the room's FIRST local member, because the adapter has to establish the channel before a broadcast from another node can reach it. Awaiting it closes that window; ignoring it is fine everywhere the subscribe and the publish aren't in the same millisecond, which is every real app and no test.

Parameters

conn

Conn

Returns

void | Promise<void>


broadcast()

broadcast<E>(event, data): void

Defined in: index.ts:211

Broadcast a shared event to all members.

Type Parameters

E

E extends string | number | symbol

Parameters

event

E

data

EmitData<EventsOf<StcOf<C["shared"]>>[E]>

Returns

void


remove()

remove(conn): void

Defined in: index.ts:209

Remove a connection from the room.

Parameters

conn

Conn

Returns

void

Released under the MIT License.