]> git.cworth.org Git - empires-server/commitdiff
Move the keepalive functionality from Empires up to Game
authorCarl Worth <cworth@cworth.org>
Thu, 4 Jun 2020 01:06:39 +0000 (18:06 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 4 Jun 2020 01:06:39 +0000 (18:06 -0700)
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.

empires.js
game.js

index 881a2c0dbdd41409bec91c6c1707323a14637e3c..744224e6b68f30a7abfe4bed34df96ceda81651f 100644 (file)
@@ -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 f1f764fa1968425d597e4e2ab47e4b8d916650a8..ca12fb3e6d302470f5cb1ce946907f3361c50474 100644 (file)
--- 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.