X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fsockets.js;h=25abadb75dabba084cdaef362cb7c7dbce682d0e;hp=65e41635d1734ec76aa4182ef5b6656cb5277673;hb=0d5335de5c94d780e03ac0aa3279b731c69455cc;hpb=58bf4670c6bf01d94fe1f798cd5d63493d15e196 diff --git a/server/sockets.js b/server/sockets.js index 65e41635..25abadb7 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -124,13 +124,12 @@ module.exports = function(wss) { // From Game let sockIds = {}; Object.keys(clients[page]).forEach(k => { - // Avoid polling myself: no new information to get - if (k != sid) { - sockIds[k] = {}; - Object.keys(clients[page][k]).forEach(x => { + sockIds[k] = {}; + Object.keys(clients[page][k]).forEach(x => { + // Avoid polling my tmpId: no information to get + if (k != sid || x != tmpId) sockIds[k][x] = { focus: clients[page][k][x].focus }; - }); - } + }); }); send(socket, { code: "pollclients", sockIds: sockIds }); break; @@ -139,30 +138,30 @@ module.exports = function(wss) { // From Hall let sockIds = {}; Object.keys(clients["/"]).forEach(k => { - // Avoid polling myself: no new information to get - if (k != sid) { - sockIds[k] = {}; - Object.keys(clients[page][k]).forEach(x => { + sockIds[k] = {}; + Object.keys(clients[page][k]).forEach(x => { + // Avoid polling my tmpId: no information to get + if (k != sid || x != tmpId) { sockIds[k][x] = { page: "/", focus: clients[page][k][x].focus }; - }); - } + } + }); }); // NOTE: a "gamer" could also just be an observer Object.keys(clients).forEach(p => { if (p.indexOf("/game/") >= 0) { Object.keys(clients[p]).forEach(k => { - if (k != sid) { - if (!sockIds[k]) sockIds[k] = {}; - Object.keys(clients[p][k]).forEach(x => { + if (!sockIds[k]) sockIds[k] = {}; + Object.keys(clients[p][k]).forEach(x => { + if (k != sid || x != tmpId) { sockIds[k][x] = { page: p, focus: clients[p][k][x].focus }; - }); - } + } + }); }); } });