- clients[obj.target].sock.send(
- JSON.stringify({code:"askchallenge",from:sid}));
- break;
- case "askgame":
- clients[obj.target].sock.send(
- JSON.stringify({code:"askgame",from:sid}));
+ clients[obj.target].sock.send(JSON.stringify(
+ {code:"askchallenge",from:sid}));
+ break;
+ case "askgames":
+ // Check all clients playing, and send them a "askgame" message
+ Object.keys(clients).forEach(k => {
+ if (k != sid && clients[k].page.indexOf("/game/") >= 0)
+ {
+ clients[k].sock.send(JSON.stringify(
+ {code:"askgame", from: sid}));
+ }
+ });