- case "enter":
- if (clients[sid].path.length > 0)
- remInArray(pages[clients[sid].path], sid);
- clients[sid].path = obj.path;
- pages[obj.path].push(sid);
- // TODO also: notify "old" sub-room that I left (if it was not index)
- if (obj.path == "/")
- {
- // Send counting info
- let countings = {};
- Object.keys(pages).forEach(
- path => { countings[path] = pages[path].length; });
- socket.send(JSON.stringify({code:"counts",counts:countings}));
- }
- else
- {
- // Send to every client connected on index an update message for counts
- pages["/"].forEach((id) => {
- clients[id].socket.send(
- JSON.stringify({code:"increase",path:obj.path}), noop);
- });
- // TODO: do not notify anything in rules and problems sections (no socket required)
- // --> in fact only /Atomic (main hall) and inside a game: /Atomic/392f3ju
- // Also notify the (sub-)room (including potential opponents):
- Object.keys(clients[page]).forEach( k => {
- clients[page][k].send(JSON.stringify({code:"connect",id:sid}), noop);
- });
- // Finally, receive (sub-)room composition
- // TODO.
- }
-// NOTE: no "leave" counterpart (because it's always to enter somewhere else)
-// case "leave":
-// break;
- // Transmit chats and moves to current room
- // TODO: WebRTC instead in this case (most demanding?)
+ case "askplayers":
+ socket.send(JSON.stringify({code:"room", players:clients}));
+ break;
+ case "askchallenges":
+ // TODO: ask directly to people (webRTC)
+ break;
+ case "askgames":
+ // TODO: ask directly to people (webRTC)
+ break;