]> git.cworth.org Git - empires-api/commitdiff
Add an initial protocol description for the tictactoe game
authorCarl Worth <cworth@cworth.org>
Wed, 27 May 2020 05:34:48 +0000 (22:34 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 27 May 2020 05:38:28 +0000 (22:38 -0700)
So far this just supports sending and receiving a move, (but what else
does Tic Tac Toe need, right?).

tictactoe.txt [new file with mode: 0644]

diff --git a/tictactoe.txt b/tictactoe.txt
new file mode 100644 (file)
index 0000000..62046a6
--- /dev/null
@@ -0,0 +1,44 @@
+Tic Tac Toe Game Protocol
+=========================
+Note: All square numbers in the protol below are as follows:
+
+       0|1|2
+       -+-+-
+       3|4|5
+       -+-+-
+       6|7|8
+
+For a specific game the following API endpoints are defined.
+(Note: Only the trailing portion of the API URI is provided here.
+ The preceding portions of the path must be determined externally.)
+
+/events
+
+    This is a server-sent events stream that allows the server to push
+    game-related events to clients. When a client connects to this API
+    endpoint the server will return a header that includes:
+
+       Content-type: text/event-stream
+       Connection: keep-alive
+       Cache-Control: no-cache
+
+    and will keep the connection open to return events.
+
+    The following event types will be returned by the server:
+
+       TYPE: move
+
+       WHEN: When a client (maybe yourself) issues a legal move
+
+       EXAMPLE:
+
+               event: move
+                data: 4
+
+/move
+
+    Method: POST
+
+    Behavior: Adds a new move to the game
+
+    Example data: { "square": 4 }