]> git.cworth.org Git - empires-server/commitdiff
Send a comment to every connected client every 15 seconds
authorCarl Worth <cworth@cworth.org>
Sun, 10 May 2020 15:40:14 +0000 (08:40 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 10 May 2020 15:40:14 +0000 (08:40 -0700)
This prevents timeouts when the client receives nothing from the
server. For example, firefox appeares to give up on the server when it
receives nothing for two minutes.

server.js

index deb0b9c58a44bf17fd3307f46831c8a3009c6d06..7a1383730d848bd118657d42d67b1729010dbfe9 100644 (file)
--- a/server.js
+++ b/server.js
@@ -11,6 +11,9 @@ class Game {
     this.next_player_id = 1;
     this.clients = [];
     this.next_client_id = 1;
+
+    /* Send a comment to every connected client every 15 seconds. */
+    setInterval(() => {this.broadcast_string(":");}, 15000);
   }
 
   add_player(name, character) {