Session
One socket’s life in the hub: pending (not yet identified) -> identified -> joined a room -> closed.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Session(
hub,conn,addr):Session
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Session
Properties
Section titled “Properties”acts:
Bucket
readonlyaddr:string
askDiv
Section titled “askDiv”askDiv:
number=1
clearAt
Section titled “clearAt”clearAt:
number=0
clock:
Bucket
clock pings: their own small bucket, and a count before sign-in
readonlyconn: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
Section titled “downAt”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=""
readonlyhub:RoomHub
lagging
Section titled “lagging”lagging:
boolean=false
lastRx
Section titled “lastRx”lastRx:
number
when the last message came in (a visible page sends a clock ping every 5 s)
listB:
Bucket
room-list requests
netDiv
Section titled “netDiv”netDiv:
number=1
opened
Section titled “opened”
readonlyopened: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
Section titled “sharedB”sharedB:
Bucket
shared writes: a bucket of their own (room.js sends at most 12.5 a second plus split parts)
slot:
string=""
slowAt
Section titled “slowAt”slowAt:
number=0
when this socket was last told too_fast
state:
Bucket
strikes
Section titled “strikes”strikes:
number=0
who:
Who|null=null
Methods
Section titled “Methods”closed()
Section titled “closed()”closed():
void
The socket closed (any reason).
Returns
Section titled “Returns”void
end(
code,reason):void
Parameters
Section titled “Parameters”number
reason
Section titled “reason”string
Returns
Section titled “Returns”void
identify()
Section titled “identify()”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.
Parameters
Section titled “Parameters”string
string
string = ""
Returns
Section titled “Returns”void
receive()
Section titled “receive()”receive(
text):void
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
send()
Section titled “send()”send(
m):void
Parameters
Section titled “Parameters”Record<string, unknown>
Returns
Section titled “Returns”void