Protocol reference
Every message on the play WebSocket, the server's close codes, the shapes the messages carry and the quick-chat phrases, generated from the protocol's contract. The page is rebuilt from the platform's contracts each time the site is built, so it always matches what the server speaks. How to connect, and the order messages come in, are in the protocol's guide.
Each frame is a JSON text message holding one object, whose type says which message it is. A field's path is written from its message: a[].b is b in each item of the list a.
Client to server
subscribe
Type: object. Attach to a match and receive its snapshot.
| Field | Type | Description |
|---|---|---|
type required | exactly subscribe | |
match required | string |
resume
Type: object. Attach after a reconnect and receive every delta after a version, read from the match's log, so a resume never needs a snapshot. A client that wants a fresh snapshot instead sends subscribe.
| Field | Type | Description |
|---|---|---|
type required | exactly resume | |
match required | string | |
version required | integer | At least 0. |
submitMove
Type: object. A move for the caller's seat; idempotent by clientSeq.
| Field | Type | Description |
|---|---|---|
type required | exactly submitMove | |
match required | string | |
clientSeq required | integer | At least 1. |
baseVersion required | integer | At least 0. |
move required | Move |
ping
Type: object. Keep-alive and latency probe.
| Field | Type | Description |
|---|---|---|
type required | exactly ping | |
sentAt | integer |
chat
Type: object. Send a quick-chat phrase to the match's other players. Refused with an error frame: chatOff (the game's policy, or a spectator), unknownPhrase, or tooFast (more than 3 in 10 seconds).
| Field | Type | Description |
|---|---|---|
type required | exactly chat | |
match required | string | |
phrase required | one of hello, goodLuck, thanks, sorry, wellPlayed, goodGame, thinking, yourTurn, niceMove, oops |
Server to client
snapshot
Type: object. The match as the seat sees it (the Player API's MatchView).
| Field | Type | Description |
|---|---|---|
type required | exactly snapshot | |
match required | string | |
snapshot required | MatchView |
delta
Type: object. One applied move, projected for the receiving seat (the Player API's Delta).
| Field | Type | Description |
|---|---|---|
type required | exactly delta | |
match required | string | |
delta required | Delta |
moveRejected
Type: object. The caller's move was rejected; codes as in the Player API.
| Field | Type | Description |
|---|---|---|
type required | exactly moveRejected | |
match required | string | |
clientSeq required | integer | |
code required | string | |
detail | string |
pong
Type: object. The answer to a ping.
| Field | Type | Description |
|---|---|---|
type required | exactly pong | |
sentAt | integer |
error
Type: object. A problem with the connection, a subscription or a chat (notFound, unauthenticated, chatOff, unknownPhrase, tooFast).
| Field | Type | Description |
|---|---|---|
type required | exactly error | |
match | string | |
code required | string | |
detail | string |
chatted
Type: object. A seat sent a quick-chat phrase. Only seated players receive it; spectators don't. The match also keeps its last 20 phrases, for up to 10 minutes and in memory only, and sends a seated player each one the game's policy allows, oldest first, when their connection subscribes or resumes, so a phrase sent before they connected still reaches them. A client that already has a phrase knows it by its id and shows it once.
| Field | Type | Description |
|---|---|---|
type required | exactly chatted | |
match required | string | |
id | string | The phrase's ID, a typed string (cht_…) unique to this sending: the same phrase sent live and again on a later subscribe has the same id. Matches ^cht_[0-9A-HJKMNP-TV-Z]{26}$. |
seat required | integer | At least 0. At most 9. |
phrase required | one of hello, goodLuck, thanks, sorry, wellPlayed, goodGame, thinking, yourTurn, niceMove, oops | |
at required | string (date and time, RFC 3339) |
seats
Type: object. Every seat as it is now (the Player API's SeatInfo): who drives it, whether its player is connected, and, while a bot may take an away player's seat over, when it will. Sent to a connection when it subscribes or resumes, and to every connection, players and spectators alike, when a player connects or goes, a grace period starts or a seat's controller changes. Not part of the log: it carries no version, and each one replaces the last.
| Field | Type | Description |
|---|---|---|
type required | exactly seats | |
match required | string | |
seats required | list of SeatInfo |
Close codes
The WebSocket close codes the server ends a connection with, besides the standard ones (1000 when the client closed, 1009 for a frame that is too big). The socket's token is checked once, at the upgrade, so the server ends the connection when that token stops being good enough. The close frame's reason is the code's name.
| Code | Name | Meaning |
|---|---|---|
| 4001 | tokenExpired | The access token the socket was opened with has expired. The client gets a fresh token (refreshing it if it hasn't already) and reconnects at once, resuming each match from its last version; this is routine, every 15 minutes or so. |
| 4003 | accountSuspended | The player's account has been suspended since the token the socket was opened with was issued, while the socket was open or before it connected. The client doesn't reconnect with that token; refreshing it is refused while the account stays suspended. |
Shapes
The Player API's shapes the messages carry, as its reference defines them. The Player API's match endpoints answer with the same shapes.
Move
Type: object. An engine move (the engine contract's Move); choices in order.
| Field | Type | Description |
|---|---|---|
action required | string | |
choices required | list of object | |
choices[].step required | string | |
choices[].value required | string |
MatchView
Type: object.
| Field | Type | Description |
|---|---|---|
match required | string | |
status required | one of created, running, paused, ended, aborted, abandoned | |
version required | integer | At least 0. |
yourSeat | integer | Absent for a spectator, who sees the public view, a round behind in a game that hides anything. At least 0. |
seats required | list of SeatInfo | |
view required | object | The engine's projection for the seat (SeatView values) |
legalActions | list of string | The actions the caller's seat may take now. |
stateHash required | string | The full state's hash, for confirming predictions. |
outcome | Outcome | |
clocks | list of Clock | The seats' clocks, for a timed match. |
seedCommitment | string | The SHA-256 of the match seed's eight bytes (big-endian), hex, published from the start. |
seed | string | The seed, 16 hex digits, once the match has ended - unless the game keeps permanent secrets. |
moves | list of LegalMove | The seat's complete legal moves, with labels, when it can act - for clients that can't rebuild the state because the game hides information. |
movesTruncated | boolean | Present and true when the seat has more legal moves than the list holds (512) |
quickChat | list of string | The quick-chat phrases the seat may send; none for a spectator or when the game's policy is none. |
SeatInfo
Type: object. A seat, who drives it, and whether its player is connected now; the play socket's seats frame sends the same shape whenever it changes.
| Field | Type | Description |
|---|---|---|
seat required | integer | At least 0. |
player | string | Absent for a bot's seat. Matches ^ply_[0-9A-HJKMNP-TV-Z]{26}$. |
controller required | one of human, bot | Who drives the seat now: bot while a bot stands in for its away player. |
connected required | boolean | Whether the seat's player has a play socket open on the match now; always false for a bot's seat. |
reconnectBy | string (date and time, RFC 3339) | While the seat's player is away and a bot may take the seat over: when the grace period ends and the bot takes it. |
Outcome
Type: object.
| Field | Type | Description |
|---|---|---|
winners required | list of integer | |
reason required | string |
Clock
Type: object. One seat's clock when the message was sent; clients count down from it.
| Field | Type | Description |
|---|---|---|
seat required | integer | At least 0. |
remainingMs required | integer | At least 0. |
running required | boolean |
LegalMove
Type: object.
| Field | Type | Description |
|---|---|---|
action required | string | |
anytime required | boolean | An any-time action, such as resigning. |
choices required | list of object | |
choices[].step required | string | |
choices[].value required | string | What the move records. |
choices[].label required | string | How to show it. |
choices[].stepLabel | string | The rules' label for the step (its label in the DSL), absent when the rules give none; the builder's text, to head the step with when the presentation manifest has none, shown as text. |
Delta
Type: object. One log entry - a move, or a change of who drives a seat, which leaves the state as it was.
| Field | Type | Description |
|---|---|---|
version required | integer | At least 1. |
seat | integer | The seat that moved or whose controller changed; absent for a system move. At least 0. |
move | Move | |
controller | one of human, bot | For a controller change only, instead of a move - a bot took the seat over after its player disconnected, or the player reclaimed it. |
view required | object | The projection after the move, for the receiving seat. |
legalActions | list of string | |
stateHash required | string | |
outcome | Outcome | |
clocks | list of Clock | The seats' clocks after the entry, for a timed match. |
moves | list of LegalMove | The receiving seat's complete legal moves after the latest entry, with labels. |
movesTruncated | boolean |
Quick-chat phrases
A chat frame sends a phrase by its ID, and clients show its text. A game whose rules limit communication allows only the courtesy phrases; one that allows none has no quick chat.
| ID | Kind | Text |
|---|---|---|
hello | courtesy | Hi! |
goodLuck | courtesy | Good luck! |
thanks | courtesy | Thanks! |
sorry | courtesy | Sorry! |
wellPlayed | courtesy | Well played |
goodGame | courtesy | Good game |
thinking | play | Thinking… |
yourTurn | play | Your turn! |
niceMove | play | Nice move! |
oops | play | Oops! |