Skip to content

Session

One socket’s life in the hub: pending (not yet identified) -> identified -> joined a room -> closed.

new Session(hub, conn, addr): Session

RoomHub

Conn

string

Session

acts: Bucket


readonly addr: string


askDiv: number = 1


clearAt: number = 0


clock: Bucket

clock pings: their own small bucket, and a count before sign-in


readonly conn: Conn


dead: boolean = false


div: number = 1

Update rate: this reader gets every div-th state frame (1, 2 or 4; effects and changes in between are merged into it, nothing is lost). netDiv is the hub’s own reading of the socket (its send queue), askDiv what the page asked for (rate {div}: a slow link or device seen by the page); the slower of the two is used, taken over only when every rate’s frame has just gone out (so nobody misses a change).


downAt: number = 0

when netDiv last went down, and since when the send queue has been near empty


early: number = 0


feats: Set<string>

what the page understands (join f: [“fxb”, …]): “fxb” = effects inside the delta frame. Pages without it get one fx message per effect.


game: string = ""


readonly hub: RoomHub


lagging: boolean = false


lastRx: number

when the last message came in (a visible page sends a clock ping every 5 s)


listB: Bucket

room-list requests


netDiv: number = 1


readonly opened: number


room: Room | null = null


rtt: number = 0

the page’s round trip to the hub (ms, its own best recent ping, sent along with its clock pings); 0 = not known


scope: string = ""


seat: Seat | null = null


sharedB: Bucket

shared writes: a bucket of their own (room.js sends at most 12.5 a second plus split parts)


slot: string = ""


slowAt: number = 0

when this socket was last told too_fast


state: Bucket


strikes: number = 0


who: Who | null = null

closed(): void

The socket closed (any reason).

void


end(code, reason): void

number

string

void


identify(scope, game, who, slot?): void

The server decided who this is (ticket or guest pass) and which namespace and game version they may join.

string

string

Who

string = ""

void


receive(text): void

string

void


send(m): void

Record<string, unknown>

void