+ // Request only one client out of 2 (TODO: this is a bit heavy)
+ // Alt: ask game to all, and filter later?
+ Object.keys(gameSids).forEach(gid => {
+ const L = gameSids[gid].length;
+ const sidIdx = L > 1
+ ? Math.floor(Math.random() * Math.floor(L))
+ : 0;
+ const tmpIdx = Object.values(gameSids[gid][sidIdx]
+ const rid = gameSids[gid][sidIdx][tmpIdx];
+ clients[sidIdx][tmpIdx].sock.send(JSON.stringify(
+ {code:"askgame", from: [sid,tmpId]}));
+ });
+ break;
+ }
+ case "askgame":
+ clients[obj.target].sock.send(JSON.stringify(
+ {code:"askgame", from:sid}));
+ break;
+ case "askfullgame":
+ clients[obj.target].sock.send(JSON.stringify(
+ {code:"askfullgame", from:sid}));
+ break;
+ case "fullgame":
+ clients[obj.target].sock.send(JSON.stringify(
+ {code:"fullgame", game:obj.game}));