From: Carl Worth Date: Thu, 4 Jun 2020 01:06:39 +0000 (-0700) Subject: Move the keepalive functionality from Empires up to Game X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=731c54ef14f2fdc852961c7c2429117d4e7472d6;hp=00507589b4984d50a34a383975fc6323db19bcfa;p=empires-server Move the keepalive functionality from Empires up to Game Since TacTacToe, (and any future game), need this too. This keepalive prevents Firefox (at least) from timing out on the server-sent-events stream after the user is idle for two minutes. --- diff --git a/empires.js b/empires.js index 881a2c0..744224e 100644 --- a/empires.js +++ b/empires.js @@ -38,9 +38,6 @@ class Empires extends Game { this.next_player_id = 1; this.characters_to_reveal = null; this.phase = GamePhase.JOIN; - - /* Send a comment to every connected client every 15 seconds. */ - setInterval(() => {this.broadcast_string(":");}, 15000); } add_spectator(name, session_id) { diff --git a/game.js b/game.js index f1f764f..ca12fb3 100644 --- a/game.js +++ b/game.js @@ -4,6 +4,9 @@ class Game { this.id = id; this.clients = []; this.next_client_id = 1; + + /* Send a comment to every connected client every 15 seconds. */ + setInterval(() => {this.broadcast_string(":");}, 15000); } /* Suport for game meta-data.