From: Benjamin Auder Date: Fri, 24 May 2019 16:58:20 +0000 (+0200) Subject: Add some thoughts on Game view X-Git-Url: https://git.auder.net/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=3b450453278327264cc285ac17f3370d4d4ce706;p=vchess.git Add some thoughts on Game view --- diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 1c25688a..10818b26 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -70,18 +70,20 @@ export default { this.gameRef.rid = this.$route.query["rid"]; this.loadGame(); } - // Poll all players except me (if I'm playing) to know online status. - // --> Send ping to server (answer pong if players[s] are connected) - if (!!this.gameRef.id) - { - this.players.forEach(p => { - if (p.sid != this.st.user.sid) - this.st.conn.send(JSON.stringify({code:"ping", oppid:p.sid})); - }); - } // TODO: how to know who is observing ? Send message to everyone with game ID ? // and then just listen to (dis)connect events + + // server always send "connect on " + URL ; then add to observers if game... + // detect multiple tabs connected (when connect ask server if my SID is already in use) +// router when access a game page tell to server I joined + game ID (no need rid) +// and ask server for current joined (= observers) +// when send to chat (or a move), reach only this group (send gid along) + + // --> doivent être enregistrés comme observers au niveau du serveur... + // non: poll users + events startObserving / stopObserving + + // TODO: also handle "draw accepted" (use opponents array?) // --> must give this info also when sending lastState... // and, if all players agree then OK draw (end game ...etc) @@ -242,6 +244,25 @@ export default { this.lastMove = (game.moves.length > 0 ? game.moves[this.cursor] : null); const vModule = await import("@/variants/" + game.vname + ".js"); window.V = vModule.VariantRules; + + + + + // Poll all players except me (if I'm playing) to know online status. + // --> Send ping to server (answer pong if players[s] are connected) + if (!!this.gameRef.id) + { + this.game.players.forEach(p => { + if (p.sid != this.st.user.sid) + this.st.conn.send(JSON.stringify({code:"ping", oppid:p.sid})); + }); + } + + + + + + }, oppConnected: function(uid) { return this.opponents.some(o => o.id == uid && o.online);