获取客户端连接时, 如果获得的client为空, 则记录该次操作

This commit is contained in:
zhl 2020-12-09 15:36:09 +08:00
parent 0f11ff6d29
commit ce4d142b2d

View File

@ -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;
}
/**