From: Carl Worth Date: Fri, 5 Jun 2020 23:35:12 +0000 (-0700) Subject: Stream player-enter events for existing players to a new player X-Git-Url: https://git.cworth.org/git?p=empires-server;a=commitdiff_plain;h=038e9507a47ff66398f01931f271159d4a0b2aa5 Stream player-enter events for existing players to a new player So they can be informed of all players that are already in the game. --- diff --git a/game.js b/game.js index 24e36ad..34a0d13 100644 --- a/game.js +++ b/game.js @@ -223,6 +223,11 @@ class Game { /* And the player-info event. */ response.write(`event: player-info\ndata: ${player.info_json()}\n\n`); + /* As well as player-enter events for all existing players. */ + this.players.filter(p => p !== player).forEach(p => { + response.write(`event: player-enter\ndata: ${p.info_json()}\n\n`); + }); + /* Finally, if this game class has a "state" property, stream that * current state to the client. */ if (this.state) {