]> git.cworth.org Git - empires-api/blob - tictactoe.txt
tictactoe: Change /move event to have data named "move", not "square"
[empires-api] / tictactoe.txt
1 Tic Tac Toe Game Protocol
2 =========================
3 Note: All square numbers in the protol below are as follows:
4
5         0|1|2
6         -+-+-
7         3|4|5
8         -+-+-
9         6|7|8
10
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.)
14
15 /events
16
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:
20
21         Content-type: text/event-stream
22         Connection: keep-alive
23         Cache-Control: no-cache
24
25     and will keep the connection open to return events.
26
27     The following event types will be returned by the server:
28
29         TYPE: game-state
30
31         WHEN: When a client first connections
32
33         EXAMPLE:
34
35                 event: game-state
36                 data: {"moves":[0,8],"board":["X","","","","","","","","O"],"next_player":"X"}
37
38         TYPE: move
39
40         WHEN: When a client (maybe yourself) issues a legal move
41
42         EXAMPLE:
43
44                 event: move
45                 data: 4
46
47 /move
48
49     Method: POST
50
51     Behavior: Adds a new move to the game
52
53     Example data: { "move": 1 }