Skip to content

CollabHub

Defined in: collab-transport.ts:260

The server half of the protocol, independent of any wire. It owns an InMemoryAuthority and routes the whole CollabMessage stream: handshake (hello → welcome + full confirm backlog + a presence replay), submit → linearize → broadcast confirm (+ reject to the author), delta sync, and presence/bye relay. Pair it with any transport — the bundled MemoryNetwork uses it in-process, and a real WebSocket server is only a dozen lines around it (see examples/collab-kitchen-sink).

Ordering contract: the hub calls client.send in canonical order per client; your transport MUST preserve that per-connection FIFO on the wire (TCP and WebSocket already do).

new CollabHub(origin?): CollabHub;

Defined in: collab-transport.ts:265

ParameterType
origin?DocumentNode

CollabHub

PropertyModifierTypeDefined in
authorityreadonlyInMemoryAuthoritycollab-transport.ts:261
add(client): void;

Defined in: collab-transport.ts:270

Register a freshly connected client. Call this before routing its messages.

ParameterType
clientHubClient

void


peers(): string[];

Defined in: collab-transport.ts:275

Connected peer ids whose handshake (hello) has completed.

string[]


receive(client, message): void;

Defined in: collab-transport.ts:282

Route one inbound message from client. May reply to it and/or broadcast.

ParameterType
clientHubClient
messageCollabMessage

void


remove(client): void;

Defined in: collab-transport.ts:324

Drop a client and announce its departure (bye) to everyone else.

ParameterType
clientHubClient

void