improved the unloading process to not create a useless socket

This commit is contained in:
kharhamel 2021-03-26 14:12:22 +01:00
parent 30e12702eb
commit 886daebfea
6 changed files with 26 additions and 22 deletions

View file

@ -471,9 +471,7 @@ export class GameScene extends ResizableScene implements CenterListener {
this.connection.onServerDisconnected(() => {
console.log('Player disconnected from server. Reloading scene.');
this.simplePeer.closeAllConnections();
this.simplePeer.unregister();
this.cleanupClosingScene();
const gameSceneKey = 'somekey' + Math.round(Math.random() * 10000);
const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile, gameSceneKey);
@ -708,6 +706,7 @@ export class GameScene extends ResizableScene implements CenterListener {
audioManager.unloadAudio();
// We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map.
this.connection?.closeConnection();
this.simplePeer.closeAllConnections();
this.simplePeer?.unregister();
this.messageSubscription?.unsubscribe();
}