Fixing suspend/resume

In case we suspend a laptop and resume it, the RECONNECT event is called by socket.io without any error being thrown (so without us being redirected to the Reconnect Scene).
This fix makes sure we go to the reconnect scene before going back to the main scene.
This commit is contained in:
David Négrier 2020-06-11 09:37:33 +02:00
parent 80fddb3c69
commit ce7b4092a6

View file

@ -168,7 +168,7 @@ export class GameManager {
private oldMapUrlFile : string;
private oldInstance : string;
private scenePlugin: ScenePlugin;
private reconnectScene: Scene;
private reconnectScene: Scene|null;
switchToDisconnectedScene(): void {
if (this.currentGameScene === null) {
return;
@ -186,8 +186,12 @@ export class GameManager {
}
reconnectToGameScene(lastPositionShared: PointInterface) {
if (this.reconnectScene === null && this.currentGameScene) {
// In case we are asked to reconnect even if switchToDisconnectedScene was not triggered (can happen when a laptop goes to sleep)
this.switchToDisconnectedScene();
}
const game : Phaser.Scene = GameScene.createFromUrl(this.oldMapUrlFile, this.oldInstance);
this.reconnectScene.scene.add(this.oldSceneKey, game, true, { initPosition: lastPositionShared });
this.reconnectScene?.scene.add(this.oldSceneKey, game, true, { initPosition: lastPositionShared });
}
private getCurrentGameScene(): GameScene {