Lint
authorRaphaël Jakse <raphael.trivabble@jakse.fr>
Sun, 12 Apr 2020 18:14:35 +0000 (20:14 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Sun, 12 Apr 2020 18:14:35 +0000 (20:14 +0200)
trivabble-server.js
trivabble.js

index 8ab91bda67bd5595aa27dabc679311c0441b6f8f..4171a1ef05c7723b0af2f0b243f7e255f9b6fa14 100644 (file)
@@ -259,14 +259,12 @@ Game.prototype.setPlayerScore = function (player, score) {
 
     this.scores[playerID] = score;
 
-    this.pendingEvents.push(
-        {
-            players: [{
-                player: player,
-                score: score
-            }]
-        }
-    );
+    this.pendingEvents.push({
+        players: [{
+            player: player,
+            score: score
+        }]
+    });
 };
 
 Game.prototype.playerJoined = function (playerName) {
@@ -322,9 +320,8 @@ Game.prototype.addListeningPlayer = function (playerName, responseAndIsES) {
 };
 
 Game.prototype.commit = function () {
-    const pendingEvents = this.pendingEvents;
+    const msg = JSON.stringify(this.pendingEvents);
     this.pendingEvents = [];
-    const msg = JSON.stringify(pendingEvents);
 
     for (let i = 0; i < this.listeningPlayers.length; i++) {
         while (i < this.listeningPlayers.length && !this.listeningPlayers[i]) {
@@ -595,8 +592,6 @@ function handleCommand(cmd, gameNumber, playerName, response) {
             const initialRackCount = countTiles(rack);
             const rackCount = countTiles(cmd.rack);
 
-            debuglog(rack, cmd.rack);
-
             if (initialRackCount !== rackCount) {
                 response.write(
                     JSON.stringify({
@@ -758,7 +753,7 @@ function handleRequest(request, response) {
                         };
 
                         for (const i in mimes) {
-                            if (request.url.endsWith(i)) {
+                            if (Object.prototype.hasOwnProperty.call(mimes, i) && request.url.endsWith(i)) {
                                 mime = mimes[i];
                                 break;
                             }
index bc28e16121d49bbd9ee96d647d824d9ec5e33f9d..1eaa1739f4cb43fe8f1ce8d3aed12bf434a539fb 100644 (file)
                     pollServerWithEventSource();
                     return;
                 }
-
-                console.log("Websocket connection has been closed", e);
                 retryPolling();
             };
         }