5 For a specific game the following API endpoints are defined.
6 (Note: Only the trailing portion of the API URI is provided here.
7 The preceding portions of the path must be determined externally.)
11 This is a server-sent events stream that allows the server to push
12 game-related events to clients. When a client connects to this API
13 endpoint the server will return a header that includes:
15 Content-type: text/event-stream
16 Connection: keep-alive
17 Cache-Control: no-cache
19 and will keep the connection open to return events.
21 The following event types will be returned by the server:
25 WHEN: When a client first connects
27 PURPOSE: Describes all players in the game already
32 data: [{"id":1,"name":"Carl"},{"id":2,"name":"Kevin"}]
36 WHEN: When a player joins the game
41 data: {"id":3,"name":"Richard"}
45 WHEN: When a player leaves the game
54 WHEN: When one player captures another
59 data: {"captor": 2, "captee": 1}
65 Behavior: Adds a new player with "name" and "character" and assigns an id. Also will add a new empire with empty "captured" array
67 Example data: { "name": "Carl", "character: "Elvis" }
73 Behavior: Removes an existing player with the given ID
79 Behavior: Removes all players (bulk deregister)
85 Behavior: Eliminates all current empire ownership so the existing
86 players can start a new game
92 Behavior: Indicate that empire ID1 has now captured ID2
98 Behavior: Indicate that empire ID is no longer captured (undoing a
105 Behavior: Returns a lists of all character names (in alphabetical order)
107 Example data: [ "Einstein", "Elvis", "Fred Flintstone" ]
113 Behavior: Shows which empires have been captured by other empires
115 Example data [ { "id": 1, "captures": [] },
116 { "id": 2, "captures": [1] },
117 { "id": 3, "captures": [4, 5, 6] },
118 { "id": 4, "captures": [2] },
119 { "id": 5, "captures": [] },
120 { "id": 6, "captures": [] } ]
126 Behavior: Gets a list of all the player objects (without their
129 Example data: [ { id: 1, name: "Carl" }, { id: 2, name: "Kevin" } ]
133 There's a sample server available at: https://families.cworth.org/api/
135 We plan to move this to https://empires.cworth.org at some point.