+ case "killme":
+ {
+ // Self multi-connect: manual removal + disconnect
+ const doKill = (pg) => {
+ Object.keys(clients[pg][obj.sid]).forEach(x => {
+ clients[pg][obj.sid][x].send(JSON.stringify({code: "killed"}));
+ });
+ delete clients[pg][obj.sid];
+ };
+ const disconnectFromOtherConnexion = (pg,code,o={}) => {
+ Object.keys(clients[pg]).forEach(k => {
+ if (k != obj.sid)
+ {
+ Object.keys(clients[pg][k]).forEach(x => {
+ clients[pg][k][x].send(JSON.stringify(Object.assign(
+ {code:code, from:obj.sid}, o)));
+ });
+ }
+ });
+ };
+ Object.keys(clients).forEach(pg => {
+ if (!!clients[pg][obj.sid])
+ {
+ doKill(pg);
+ disconnectFromOtherConnexion(pg, "disconnect");
+ if (pg.indexOf("/game/") >= 0)
+ disconnectFromOtherConnexion("/", "gdisconnect", {page:pg});
+ }
+ });
+ break;
+ }