info_json() {
return JSON.stringify({
id: this.id,
+ active: this.active,
name: this.name,
team: this.team.name,
score: this.score
this.broadcast_event("player-enter", existing.info_json());
}
existing.add_connection(connection);
+ this.players_by_session[session.id] = existing;
return existing;
}
response.write(`event: player-info\ndata: ${player.info_json()}\n\n`);
/* As well as player-enter events for all existing, active players. */
- this.players.filter(p => p !== player && p.active).forEach(p => {
+ this.players.filter(
+ p => (p !== player
+ && (p.active || p.score))).forEach(p => {
response.write(`event: player-enter\ndata: ${p.info_json()}\n\n`);
});