<!-- TODO: component Game, + handle players + observers connect/disconnect
event = "gameconnect" ...etc
connect/disconnect with sid+name (ID not required); name slightly redundant but easier
+
+quand on arrive dans la partie, on poll les sids pour savoir qui est en ligne (ping)
+(éventuel échange lastate avec les connectés, pong ...etc)
+ensuite quand qqun se deco il suffit d'écouter "disconnect"
+pareil quand quelqu'un reco.
+(c'est assez rudimentaire et écoute trop de messages, mais dans un premier temps...)
-->
obj.oppid = sid; //I'm the opponent of my opponent(s)
clients[oppId].send(JSON.stringify(obj));
break;
- // TODO: moreover, here, game info should be sent (through challenge; not stored here)
- // TODO: also other challenge events
case "resign":
clients[obj.target].send(JSON.stringify({code:"resign"}));
break;
- // TODO: case "challenge" (get ID) --> send to all, "acceptchallenge" (with ID) --> send to all, "cancelchallenge" --> send to all
- // also, "sendgame" (give current game info, if any) --> to new connections, "sendchallenges" (same for challenges) --> to new connections
}
});
socket.on("close", () => {