diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index 9aa17d5..f8f19d4 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -106,12 +106,17 @@ export class GeneralRoom extends Room { this.dispatcher.stop(); } - getClient(player: string | Player) { + getClient(player: string | Player): Client { + let result: Client; if (typeof player == 'string') { - return this.clients.find(client => client.sessionId == player ); + result = this.clients.find(client => client.sessionId == player ); } else { - return this.clients.find(client => client.sessionId == player.id ); + result = this.clients.find(client => client.sessionId == player.id ); } + if (!result) { + error(`无法获取id为: ${typeof player == 'string' ? player : player.id} 的客户端`) + } + return result; } /**