Some fixes. TODO: game.mode must be analyze when score is not '*' ==> simplify Board...
[vchess.git] / server / sockets.js
index 127b7fa..d92778c 100644 (file)
@@ -31,6 +31,7 @@ module.exports = function(wss) {
   wss.on("connection", (socket, req) => {
     const query = getJsonFromUrl(req.url);
     const sid = query["sid"];
+    // TODO: later, allow duplicate connections (shouldn't be much more complicated)
     // Ignore duplicate connections (on the same live game that we play):
     if (!!clients[sid])
       return socket.send(JSON.stringify({code:"duplicate"}));
@@ -114,6 +115,9 @@ module.exports = function(wss) {
         case "resign":
           clients[obj.target].send(JSON.stringify({code:"resign"}));
           break;
+        case "abort":
+          clients[obj.target].send(JSON.stringify({code:"abort",msg:obj.msg}));
+          break;
       }
     });
     socket.on("close", () => {