Finish Ultima rules + a few technical fixes
[vchess.git] / sockets.js
index ee4c1cf..675a80e 100644 (file)
@@ -25,6 +25,12 @@ module.exports = function(wss) {
                const params = new URL("http://localhost" + req.url).searchParams;
                const sid = params.get("sid");
                const page = params.get("page");
+               // Ignore duplicate connections:
+               if (!!clients[page][sid])
+               {
+                       socket.send(JSON.stringify({code:"duplicate"}));
+                       return;
+               }
                clients[page][sid] = socket;
                if (page == "index")
                {