X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Fsockets.js;h=fcda981624f00650a8174dd5b8b79b5f0d15b090;hb=f6f2bef10910ddb3430a40f4ab393b225250234a;hp=09434a02b75ea53228d61f0a91ca606459e8a577;hpb=6fba6e0c029afc74a780ef845a02659da53c84e0;p=vchess.git diff --git a/server/sockets.js b/server/sockets.js index 09434a02..fcda9816 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -83,14 +83,13 @@ module.exports = function(wss) { case "newchat": clients[obj.target].send(JSON.stringify({code:"newchat",msg:obj.msg})); break; - // Transmit chats and moves to current room // TODO: WebRTC instead in this case (most demanding?) case "newmove": clients[obj.target].send(JSON.stringify({code:"newmove",move:obj.move})); break; - // TODO: generalize that for several opponents case "ping": - socket.send(JSON.stringify({code:"pong",gameId:obj.gameId})); + // If this code is reached, then obj.target is connected + socket.send(JSON.stringify({code:"pong"})); break; case "lastate": const oppId = obj.target; @@ -103,6 +102,12 @@ module.exports = function(wss) { case "abort": clients[obj.target].send(JSON.stringify({code:"abort",msg:obj.msg})); break; + case "drawoffer": + clients[obj.target].send(JSON.stringify({code:"drawoffer"})); + break; + case "draw": + clients[obj.target].send(JSON.stringify({code:"draw"})); + break; } }); socket.on("close", () => {