From 817b25b0bebbe7877596b60d6577007aac2b32f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 17 Jun 2020 16:06:02 +0200 Subject: [PATCH] Fixing reconnect issue In the case the reconnect event was triggered on "wake-up", the disconnect event was not sent. But because of a bug in the way we handle the setTimeout, the reconnection to the GameScene never happened after we forced the disconnect scene. This fixes the issue. --- front/src/Connection.ts | 1 + front/src/Phaser/Game/GameManager.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/front/src/Connection.ts b/front/src/Connection.ts index 636caf58..baa9c8a4 100644 --- a/front/src/Connection.ts +++ b/front/src/Connection.ts @@ -325,6 +325,7 @@ export class Connection implements ConnectionInterface { }); this.getSocket().on(EventMessage.RECONNECT, () => { + console.log('Reconnect event triggered'); this.connectSocketServer(); if (this.lastPositionShared === null) { throw new Error('No last position shared found while reconnecting'); diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index 8dbceec9..7ed0137f 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -204,8 +204,8 @@ export class GameManager { // Wait a bit for scene to load. Otherwise, starting ReconnectingSceneName and then starting GameScene one after the other fails for some reason. this.timeoutCallback = setTimeout(() => { console.log('Reconnecting to game scene from setTimeout'); - this.reconnectToGameScene(lastPositionShared); this.timeoutCallback = null; + this.reconnectToGameScene(lastPositionShared); }, 500); return; }