Fix rematch process
[vchess.git] / server / sockets.js
index f3224f1..d1489f7 100644 (file)
@@ -42,10 +42,10 @@ module.exports = function(wss) {
       });
     };
     // For focus events: no need to target self
-    const notifyAllButMe = (page,code,obj={}) => {
+    const notifyAllBut = (page,code,obj={},except) => {
       if (!clients[page]) return;
       Object.keys(clients[page]).forEach(k => {
-        if (k == sid) return;
+        if (except.includes(k)) return;
         Object.keys(clients[page][k]).forEach(x => {
           send(
             clients[page][k][x].socket,
@@ -205,7 +205,7 @@ module.exports = function(wss) {
 
         case "rnewgame":
           // A rematch game started: players are already informed
-          notifyAllBut(page, "newgame", {data: obj.data}, [sid, obj.oppsid]);
+          notifyAllBut(page, "newgame", {data: obj.data}, [sid]);
           notifyAllBut("/", "newgame", {data: obj.data}, [sid, obj.oppsid]);
           notifyRoom("/mygames", "newgame", {data: obj.data});
           break;