- notifyRoom(query["page"], "connect"); //Hall or Game
- socket.on("message", objtxt => {
+ const deleteConnexion = () => {
+ if (!clients[page] || !clients[page][sid] || !clients[page][sid][tmpId])
+ return; //job already done
+ delete clients[page][sid][tmpId];
+ if (Object.keys(clients[page][sid]).length == 0)
+ {
+ delete clients[page][sid];
+ if (Object.keys(clients[page]) == 0)
+ delete clients[page];
+ }
+ };
+ const doDisconnect = () => {
+ deleteConnexion();
+ if (!clients[page] || !clients[page][sid])
+ {
+ // I effectively disconnected from this page:
+ notifyRoom(page, "disconnect");
+ if (page.indexOf("/game/") >= 0)
+ notifyRoom("/", "gdisconnect", {page:page});
+ }
+ };
+ const messageListener = (objtxt) => {