Skip to content

PlayerTarget

What a function takes where it wants a player: the PlayerSnapshot or the player’s ID. Pass the snapshot when you can: it reaches only the connection it came from, while an ID reaches whoever has it now.

type PlayerTarget = number | PlayerSnapshot;
Value Type Means
a PlayerSnapshot PlayerSnapshot That player’s connection. A function whose player left meanwhile returns { status: "rejected", code: "session-ended" } or stale-target.
a number number The player with that ID now. 0 means everyone, where a function says so.