X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=tictactoe.js;h=7b91a9bc34461158d41fd1d1495cdc84d33600c0;hb=2c93bc13fb20e23084671ca3dc92ce9ee3e33494;hp=74cf3436334f214123981d8698b17b0cacf8ae21;hpb=bceb4cb3eb1b150aedc562978df01cb0ac4ce628;p=empires-server diff --git a/tictactoe.js b/tictactoe.js index 74cf343..7b91a9b 100644 --- a/tictactoe.js +++ b/tictactoe.js @@ -37,10 +37,10 @@ class TicTacToe extends Game { handle_events(request, response) { super.handle_events(request, response); - /* When a new client joins, replay all previous moves to it. */ - for (let move of this.state.moves) { - response.write(`event: move\ndata: ${move}\n\n`); - } + /* When a new client joins, give them the current game state, + * (which includes the history of moves). */ + const state_json = JSON.stringify(this.state); + response.write(`event: game-state\ndata: ${state_json}\n\n`); } }