From 038e9507a47ff66398f01931f271159d4a0b2aa5 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 5 Jun 2020 16:35:12 -0700 Subject: [PATCH] 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. --- game.js | 5 +++++ 1 file changed, 5 insertions(+) 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) { -- 2.43.0