获取客户端连接时, 如果获得的client为空, 则记录该次操作
This commit is contained in:
parent
0f11ff6d29
commit
ce4d142b2d
@ -106,12 +106,17 @@ export class GeneralRoom extends Room {
|
|||||||
this.dispatcher.stop();
|
this.dispatcher.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
getClient(player: string | Player) {
|
getClient(player: string | Player): Client {
|
||||||
|
let result: Client;
|
||||||
if (typeof player == 'string') {
|
if (typeof player == 'string') {
|
||||||
return this.clients.find(client => client.sessionId == player );
|
result = this.clients.find(client => client.sessionId == player );
|
||||||
} else {
|
} 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user