]> git.cworth.org Git - empires-api/blobdiff - api.text
Add a version indication to the protocol description
[empires-api] / api.text
index f4ea703d3cd33d49f30845a5646eb54bae3f04d1..41e365c65e3df41a6151cda5d057e956c1bb52f3 100644 (file)
--- a/api.text
+++ b/api.text
@@ -1,5 +1,63 @@
-Gameplay API endpoints (within a current game)
-==============================================
+Empires Game Protocol
+=====================
+Version: 0.3
+
+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: players
+
+       WHEN: When a client first connects
+
+       PURPOSE: Describes all players in the game already
+
+       EXAMPLE:
+
+               event: players
+                data: [{"id":1,"name":"Carl"},{"id":2,"name":"Kevin"}]
+
+       TYPE: player-join
+
+       WHEN: When a player joins the game
+
+       EXAMPLE:
+
+               event: player-join
+                data: {"id":3,"name":"Richard"}
+
+       TYPE: player-leave
+
+       WHEN: When a player leaves the game
+
+       EXAMPLE:
+
+               event: player-leave
+               data: {"id":3}
+
+       TYPE: capture
+
+       WHEN: When one player captures another
+
+       EXAMPLE:
+
+               event: capture
+               data: {"captor": 2, "captee": 1}
+
 /register
 
     Method: POST