X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fsockets.js;h=42a8840fc51fb014e593c6312b9315b62ca50ca4;hp=1cc47aeb454eb2bb6889a00cac891d4574a9d5bb;hb=8477e53d8e78606e4c4e4bf91c77b1011aab583c;hpb=df647c70b4148894c7d87fc499df5a9050347aec diff --git a/server/sockets.js b/server/sockets.js index 1cc47aeb..42a8840f 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -153,7 +153,7 @@ module.exports = function(wss) { { const pg = obj.page || page; //required for askidentity and askgame // In cas askfullgame to wrong SID for example, would crash: - if (!!clients[pg][obj.target]) + if (clients[pg] && clients[pg][obj.target]) { const tmpIds = Object.keys(clients[pg][obj.target]); if (obj.target == sid) //targetting myself @@ -207,7 +207,10 @@ module.exports = function(wss) { case "lastate": { const pg = obj.target[2] || page; //required for identity and game - send(clients[pg][obj.target[0]][obj.target[1]], {code:obj.code, data:obj.data}); + // NOTE: if in game we ask identity to opponent still in Hall, + // but leaving Hall, clients[pg] or clients[pg][target] could be ndefined + if (clients[pg] && clients[pg][obj.target[0]]) + send(clients[pg][obj.target[0]][obj.target[1]], {code:obj.code, data:obj.data}); break; } }