- this.send("newmove", {data: sendMove});
- // If the opponent doesn't reply gotmove soon enough, re-send move:
- // Do this at most 2 times, because more would mean network issues,
- // opponent would then be expected to disconnect/reconnect.
- let counter = 1;
- const currentUrl = document.location.href;
- this.retrySendmove = setInterval(
- () => {
- if (
- counter >= 3 ||
- this.opponentGotMove ||
- document.location.href != currentUrl //page change
- ) {
- clearInterval(this.retrySendmove);
- return;
- }
- const oppsid = this.getOppsid();
- if (!oppsid)
- // Opponent is disconnected: he'll ask last state
- clearInterval(this.retrySendmove);
- else {
- this.send("newmove", { data: sendMove, target: oppsid });
- counter++;
- }
- },
- 1500
- );