Merge branch 'master' of http://git.kingsome.cn/node/card_svr
This commit is contained in:
commit
c25995fdc9
@ -88,30 +88,35 @@ export class GeneralRoom extends Room {
|
||||
}
|
||||
//TODO: 掉线逻辑
|
||||
async onLeave (client: Client, consented: boolean) {
|
||||
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_OFFLINE;
|
||||
|
||||
try {
|
||||
if (consented) {
|
||||
throw new Error("consented leave");
|
||||
}
|
||||
await this.allowReconnection(client, 60);
|
||||
this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_NORMAL;
|
||||
|
||||
} catch (e) {
|
||||
this.state.players.delete(client.sessionId);
|
||||
}
|
||||
// this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_OFFLINE;
|
||||
//
|
||||
// try {
|
||||
// if (consented) {
|
||||
// throw new Error("consented leave");
|
||||
// }
|
||||
// await this.allowReconnection(client, 60);
|
||||
// this.state.players.get(client.sessionId).state = PlayerStateConst.PLAYER_NORMAL;
|
||||
//
|
||||
// } catch (e) {
|
||||
// this.state.players.delete(client.sessionId);
|
||||
// }
|
||||
}
|
||||
|
||||
onDispose() {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user