state and input default to priority 100. Events default to priority 50.
Set a higher priority on a critical event to put it above the rest of its lane.
Pass onState to watch the link. The session reconnects and replays your
channels automatically. You do not re-subscribe by hand.
const me = new Games({ relayHost, token, roomId: "duel-42", playerId: "alice", onState: (s) => { if (s === 1) showOnline(); if (s === 2) showReconnecting(); },});
me = Games( token=tok, room_id="duel-42", player_id="alice", on_state=lambda s, reason=None: ( show_online() if s == 1 else show_reconnecting() if s == 2 else None ),)
Player ids must encode to 255 UTF-8 bytes or fewer, because the wire header
has one length byte. Check untrusted ids on the client.
if (new TextEncoder().encode(playerId).length > 255) { throw new Error("player id too long");}
if len(player_id.encode("utf-8")) > 255: raise ValueError("player id too long")
To select a channel: if a newer message will replace a dropped message, use
state or input (datagram, latest-wins). If a player will miss a dropped
message, use an event (reliable, ordered).