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).
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CollabHub(origin?): CollabHub;Defined in: collab-transport.ts:265
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
origin? | DocumentNode |
Returns
Section titled “Returns”CollabHub
Properties
Section titled “Properties”| Property | Modifier | Type | Defined in |
|---|---|---|---|
authority | readonly | InMemoryAuthority | collab-transport.ts:261 |
Methods
Section titled “Methods”add(client): void;Defined in: collab-transport.ts:270
Register a freshly connected client. Call this before routing its messages.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
client | HubClient |
Returns
Section titled “Returns”void
peers()
Section titled “peers()”peers(): string[];Defined in: collab-transport.ts:275
Connected peer ids whose handshake (hello) has completed.
Returns
Section titled “Returns”string[]
receive()
Section titled “receive()”receive(client, message): void;Defined in: collab-transport.ts:282
Route one inbound message from client. May reply to it and/or broadcast.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
client | HubClient |
message | CollabMessage |
Returns
Section titled “Returns”void
remove()
Section titled “remove()”remove(client): void;Defined in: collab-transport.ts:324
Drop a client and announce its departure (bye) to everyone else.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
client | HubClient |
Returns
Section titled “Returns”void