projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix clocks update
[vchess.git]
/
server
/
sockets.js
diff --git
a/server/sockets.js
b/server/sockets.js
index
e94f623
..
d92778c
100644
(file)
--- a/
server/sockets.js
+++ b/
server/sockets.js
@@
-31,6
+31,7
@@
module.exports = function(wss) {
wss.on("connection", (socket, req) => {
const query = getJsonFromUrl(req.url);
const sid = query["sid"];
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"}));
// Ignore duplicate connections (on the same live game that we play):
if (!!clients[sid])
return socket.send(JSON.stringify({code:"duplicate"}));
@@
-83,6
+84,10
@@
module.exports = function(wss) {
clients[obj.target].send(
JSON.stringify({code:"refusechallenge", cid:obj.cid, from:sid}));
break;
clients[obj.target].send(
JSON.stringify({code:"refusechallenge", cid:obj.cid, from:sid}));
break;
+ case "deletechallenge":
+ clients[obj.target].send(
+ JSON.stringify({code:"deletechallenge", cid:obj.cid, from:sid}));
+ break;
case "newgame":
clients[obj.target].send(JSON.stringify(
{code:"newgame", gameInfo:obj.gameInfo, cid:obj.cid}));
case "newgame":
clients[obj.target].send(JSON.stringify(
{code:"newgame", gameInfo:obj.gameInfo, cid:obj.cid}));
@@
-110,6
+115,9
@@
module.exports = function(wss) {
case "resign":
clients[obj.target].send(JSON.stringify({code:"resign"}));
break;
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", () => {
}
});
socket.on("close", () => {