get client方法可传string或者player对象
This commit is contained in:
parent
393afe0bfa
commit
dbeeec1d00
5
src/global.d.ts
vendored
5
src/global.d.ts
vendored
@ -7,6 +7,7 @@ import {PartResultMsg} from "./message/PartResult";
|
||||
import {RemovePetMsg} from "./message/RemovePetMsg";
|
||||
import {Dispatcher} from "@colyseus/command";
|
||||
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
||||
import {Player} from "./rooms/schema/Player";
|
||||
|
||||
export {};
|
||||
|
||||
@ -30,9 +31,9 @@ declare module "colyseus" {
|
||||
mainClock: Delayed;
|
||||
/**
|
||||
* 根据sessionId获取client
|
||||
* @param sessionId
|
||||
* @param player 玩家id或者玩家的对象
|
||||
*/
|
||||
getClient(sessionId: string): Client;
|
||||
getClient(player: string | Player): Client;
|
||||
// >>>>>>>>> Begin of extend send message <<<<<<<<<<<<<
|
||||
/**
|
||||
* 广播玩家加入房间
|
||||
|
@ -14,6 +14,7 @@ import {debugRoom, error, msgLog} from "../common/Debug";
|
||||
import {Delayed} from "@gamestdio/timer/lib/Delayed";
|
||||
import {IncomingMessage} from "http";
|
||||
import {PlayerStateConst} from "../constants/PlayerStateConst";
|
||||
import {Player} from "./schema/Player";
|
||||
|
||||
|
||||
export class GeneralRoom extends Room {
|
||||
@ -105,8 +106,12 @@ export class GeneralRoom extends Room {
|
||||
this.dispatcher.stop();
|
||||
}
|
||||
|
||||
getClient(sessionId: string) {
|
||||
return this.clients.find(client => client.sessionId == sessionId );
|
||||
getClient(player: string | Player) {
|
||||
if (typeof player == 'string') {
|
||||
return this.clients.find(client => client.sessionId == player );
|
||||
} else {
|
||||
return this.clients.find(client => client.sessionId == player.id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user