- // (resign, newgame, newmove). See https://github.com/websockets/ws/blob/master/lib/websocket.js around line 313
- // TODO: awaiting newmove, resign, (+newgame?) :: in memory structure (use Redis ?)
- let newmoves = {};
- let newresign = {};
- for (const v of Variants)
- {
- newmoves[v.name] = {};
- newresign[v.name] = {};
- }
+// // Safety counter (TODO: is it necessary ?)
+// setInterval(() => {
+// Object.keys(clients).forEach(k => {
+// Object.keys(clients[k]).forEach(ck => {
+// if (!clients[k][ck] || clients[k][ck].readyState != 1)
+// delete clients[k][ck];
+// });
+// });
+// }, 60000); //every minute (will be lowered if a lot of users...)
+
+ // No-op function as a callback when sending messages
+ const noop = () => { };