- socket.send(JSON.stringify({code:"pollgamers",
- sockIds: Object.keys(clients).filter(k =>
- k != sid && clients[k].page.indexOf("/game/") >= 0
- )}));
- break;
- case "pagechange":
- // page change clients[sid].page --> obj.page
- // TODO: some offline rooms don't need to receive disconnect event
- notifyRoom(clients[sid].page, "disconnect");
- if (clients[sid].page.indexOf("/game/") >= 0)
- notifyRoom("/", "gdisconnect");
- clients[sid].page = obj.page;
- // No need to notify connection: it's self-sent in .vue file
- //notifyRoom(obj.page, "connect");
- if (obj.page.indexOf("/game/") >= 0)
- notifyRoom("/", "gconnect");
+ {
+ let sockIds = {};
+ Object.keys(clients).forEach(k => {
+ Object.keys(clients[k]).forEach(x => {
+ if ((k != sid || x != tmpId)
+ && clients[k][x].page.indexOf("/game/") >= 0)
+ {
+ if (!sockIds[k])
+ sockIds[k] = [x];
+ else
+ sockIds[k].push(x);
+ }
+ });
+ });
+ socket.send(JSON.stringify({code:"pollgamers", sockIds:sockIds}));