Carl Worth [Sun, 10 May 2020 15:40:14 +0000 (08:40 -0700)]
Send a comment to every connected client every 15 seconds
This prevents timeouts when the client receives nothing from the
server. For example, firefox appeares to give up on the server when it
receives nothing for two minutes.
Carl Worth [Sun, 10 May 2020 15:35:21 +0000 (08:35 -0700)]
Rename broadcast() to broadcast_event() supported by broadcast_string()
The lower-level broadcast_string() simply sends a string to all clients.
The higher-level broadcast_event() sends a structured event (with both an
event type and a separate data block, as well as ending with two newlines),
exactly as clients will be expecting.
Carl Worth [Sun, 3 May 2020 22:03:56 +0000 (15:03 -0700)]
Add some linting fixes
Specifically some missing semicolons and a missing const.
It's funny that I didn't realize that emacs was doing live linting of
JavaScript all along here, (and highlighting all problems with various
colors and underlining).
Carl Worth [Sun, 3 May 2020 02:24:34 +0000 (19:24 -0700)]
Add simple testing for the entire API
This is more "exercising" than testing, (it doesn't currently verify
the results), but I've verified the server isn't hitting any syntax
errors (with fairly decent code coverage I think) and I've manually
inspected the results to ensure they look correct.
Carl Worth [Sat, 2 May 2020 23:53:13 +0000 (16:53 -0700)]
Add an ID value to each player
This is a first baby step toward implementing the more complete API
for the game which we defined today, and which can be found here:
https://git.cworth.org/git/empires-api
In this commit we also introduce a 'Game' class to encapsulate all
data necessary for the game, (so the 'players' array we had before,
but also the 'next_player_id' which we need now).