1 Tic Tac Toe Game Protocol
2 =========================
3 Note: All square numbers in the protol below are as follows:
11 For a specific game the following API endpoints are defined.
12 (Note: Only the trailing portion of the API URI is provided here.
13 The preceding portions of the path must be determined externally.)
17 This is a server-sent events stream that allows the server to push
18 game-related events to clients. When a client connects to this API
19 endpoint the server will return a header that includes:
21 Content-type: text/event-stream
22 Connection: keep-alive
23 Cache-Control: no-cache
25 and will keep the connection open to return events.
27 The following event types will be returned by the server:
31 WHEN: When a client first connects
33 WHAT: Static information about the game (will not change)
38 data: {"id":"WXYZ","url":"https://lmno.games/WXYZ"}
42 WHEN: When a client first connects
44 WHAT: Information about the current player (ID, name, and team)
46 NOTE: The player-info event is unique among player-* events in
47 that it only describes the player associated with the
48 current client connection. Meanwhile, player-enter and
49 player-update events can describe the current player or
50 any other. The player-info event is significant because
51 the client may not know its own name other than
52 receiving it here, (such as if the client offers up a
53 pre-existing cookie and the server uses that to return a
54 player name from a server-side session object).
59 data: {"id":0,"name":"Carl","team":"X"}
63 WHEN: Whenever a new player enters the game. Also: these
64 events will be streamed out for all existing players
65 when a client first connects
67 WHAT: Information about the new player (ID, name, and team)
72 data: {"id":1,"name":"Stacy","team":"O"}
76 WHEN: Whenever a player updates their information
78 WHAT: All information about the updating player. The ID value
79 cannot be changed, so it can be used by the client to
80 know which player object to update. Player may change
81 either their name, their team, or both.
86 data: {"id":0,"name":"Carl Worth","team":"O"}
90 WHEN: When a client first connects
92 WHAT: Snapshot of the current dynamic game state
97 data: {"moves":[0,8],"board":["X","","","","","","","","O"],"next_player":"X"}
101 WHEN: When a client (maybe yourself) issues a legal move
112 Behavior: Adds a new move to the game
114 Example data: { "move": 1 }