Stop sending all player information to everyone on many actions
authorRaphaël Jakse <raphael.trivabble@jakse.fr>
Sun, 12 Apr 2020 18:14:36 +0000 (20:14 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Sun, 12 Apr 2020 18:14:36 +0000 (20:14 +0200)
trivabble-server.js

index 4171a1ef05c7723b0af2f0b243f7e255f9b6fa14..7bbabc9392daf023aee17480de1963f9624cbdd8 100644 (file)
@@ -442,22 +442,20 @@ function countTiles(rack) {
     return count;
 }
 
-function joinGame(gameNumber, playerName) {
+function joinGame(gameNumber) {
     if (!gameNumber) {
         gameNumber = newGameId();
     }
 
     const game = games[gameNumber] || (games[gameNumber] = new Game());
 
-    game.playerJoined(playerName);
-
     return {gameNumber, game};
 }
 
 function handleCommand(cmd, gameNumber, playerName, response) {
     let game;
 
-    ({gameNumber, game} = joinGame(gameNumber, playerName));
+    ({gameNumber, game} = joinGame(gameNumber));
     game.lastUpdated = new Date();
 
     let rack = null;
@@ -664,7 +662,7 @@ function handleCommand(cmd, gameNumber, playerName, response) {
 
 function handleCommands(cmds, responseAndIsES) {
     if (!cmds.cmds || !cmds.cmds.length) {
-        const {gameNumber, game} = joinGame(cmds.gameNumber, cmds.playerName);
+        const {gameNumber, game} = joinGame(cmds.gameNumber);
 
         writeResponse(responseAndIsES,
             JSON.stringify({