Announce the server version
authorRaphaël Jakse <raphael.trivabble@jakse.fr>
Tue, 28 Apr 2020 17:27:37 +0000 (19:27 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Tue, 28 Apr 2020 17:27:42 +0000 (19:27 +0200)
trivabble-server.js
trivabble.js

index 51829a9ba0edbc197cccd7df1b6574b818279cd5..2ffcaf4e45b6292049cb55abd89eccb60a88d956 100644 (file)
@@ -31,6 +31,8 @@ const port = parseInt(process.env.TRIVABBLE_PORT || "3000");
 const SAVE_TIMEOUT = 5000;
 const KEEP_ALIVE = 30000;
 
+const VERSION = 202004281800;
+
 function envTrue(name) {
     return (process.env[name] || "").toLowerCase() === "true";
 }
@@ -519,13 +521,15 @@ function handleCommand(cmdNumber, message, response) {
                 rack: game.getPlayerRack(playerName),
                 board: game.board,
                 remainingLetters: game.bag.length,
-                letterValues: frValues
+                letterValues: frValues,
+                version: VERSION
             });
             break;
         }
 
         case "hello": {
             game.playerJoined(playerName);
+            reply(message, response, cmdNumber, {error: 0, version: VERSION});
             break;
         }
 
@@ -730,7 +734,8 @@ function handleCommands(message, responseAndType) {
                 letterValues:     game.letterValues,
                 rack:             game.getPlayerRack(message.playerName),
                 board:            game.board,
-                remainingLetters: game.bag.length
+                remainingLetters: game.bag.length,
+                version:          VERSION
             })
         );
 
index b5b502644e1a26b15c4c868d1e9dc2fcefa007c8..022b92d50571593af6900ecf16a260167ffbd2ad 100644 (file)
@@ -88,6 +88,8 @@
     let pollingServer = false;
     let connectionStopped = false;
 
+    let serverVersion = 0;
+
     // HTTP path url prefix for any socket (xhr,ess or ws) from browser to server access
     function getApiEntryPoint() {
         return Conf.APP_PATH + "/:trivabble";
             return;
         }
 
+        if (data.version) {
+            serverVersion = data.version;
+        }
+
         if (data.pleaseRestart) {
             forceReload(_("Sorry to disturb you, but we need to reload the game so you can continue playing. You will not lose anything except the messages in the chat. Are you ready?"));
         }