From de1ff7bcae314bb23cea16d02e6381d3b6b758bd Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 16 Dec 2020 15:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E7=A6=BB=E5=BC=80=E6=97=B6,=20=E6=9D=A1=E7=94=A8leave=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/RobotClient.ts | 1 - src/rooms/GeneralRoom.ts | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/robot/RobotClient.ts b/src/robot/RobotClient.ts index d140e8e..faa7594 100644 --- a/src/robot/RobotClient.ts +++ b/src/robot/RobotClient.ts @@ -52,7 +52,6 @@ export class RobotClient implements Client { leave(code?: number, data?: string): void { this.listenerState && this.listenerState(); this.listenerTurn && this.listenerTurn(); - this.ref.emit('close'); } raw(data: ArrayLike, options?: ISendOptions): void { diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index 799abd0..c1dfc4e 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -105,7 +105,10 @@ export class GeneralRoom extends Room { async onLeave (client: Client, consented: boolean) { if (this.state.gameState === GameStateConst.STATE_GAME_OVER || this.state.gameState === GameStateConst.STATE_WAIT_JOIN) { this.state.players.delete(client.sessionId); - this.assistMap.delete(client.sessionId); + if (this.assistMap.has(client.sessionId)) { + this.assistMap.get(client.sessionId).leave(); + this.assistMap.delete(client.sessionId); + } this.bUserLeft(client.sessionId); } else { this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_OFFLINE;