+ // Send move ("newmove" event) to people in the room (if our turn)
+ if (moveCol == this.game.mycolor && !data.receiveMyMove) {
+ const sendMove = {
+ move: filtered_move,
+ index: origMovescount,
+ // color is required to check if this is my move (if several tabs opened)
+ color: moveCol,
+ addTime: addTime, //undefined for corr games
+ cancelDrawOffer: this.drawOffer == ""
+ };
+ this.opponentGotMove = false;
+ this.send("newmove", {data: sendMove});
+ // If the opponent doesn't reply gotmove soon enough, re-send move:
+ let retrySendmove = setInterval( () => {
+ if (this.opponentGotMove) {
+ clearInterval(retrySendmove);
+ return;
+ }
+ let oppsid = this.game.players[nextIdx].sid;
+ if (!oppsid) {
+ oppsid = Object.keys(this.people).find(
+ sid => this.people[sid].id == this.game.players[nextIdx].uid
+ );
+ }
+ if (!oppsid || !this.people[oppsid])
+ // Opponent is disconnected: he'll ask last state
+ clearInterval(retrySendmove);
+ else this.send("newmove", {data: sendMove, target: oppsid});
+ }, 750);
+ }