X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=api.text;h=48a2eb6b072c499795d0d81a9451ce59ff37ee01;hb=39b74cde47375adaeacc33507a2173b63e3de10c;hp=4bf4d0380db226fb73a8c83dffd4b2fe6fff1f8e;hpb=0411bdc5c4dbad187f7e25fa1fb40a23c3e0e940;p=empires-api diff --git a/api.text b/api.text index 4bf4d03..48a2eb6 100644 --- a/api.text +++ b/api.text @@ -1,5 +1,57 @@ Gameplay API endpoints (within a current game) ============================================== +/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 @@ -72,6 +124,6 @@ Gameplay API endpoints (within a current game) Server ====== -There's a sample server available at: https://families.cworth.org/ +There's a sample server available at: https://families.cworth.org/api/ We plan to move this to https://empires.cworth.org at some point.