-
Notifications
You must be signed in to change notification settings - Fork 77
i_en_app
appName: string
- Application Name
readonly base: string
- Root path
readonly env: string
- Startup environment
readonly serverId: string
- Server id
readonly serverType: string
- Server type
readonly serverInfo: ServerInfo
- The configuration of this server
readonly routeConfig: string[]
- configuration:route.ts
readonly masterConfig: ServerInfo
- configuration:master.ts
readonly serversConfig: { [serverType: string]: ServerInfo[] }
- configuration:servers.ts
readonly startTime: number
- Server start time
readonly clientNum: number
- The number of all socket connections
(frontend server call)
start(): void
- Start the server
rpc(serverId: string, notify?: boolean): Rpc
- rpc call
setConfig(key: string, value: any): void
set<T = any>(key: string | number, value: T): T
- Set key-value pairs
get<T = any>(key: string | number): T
- Get key-value pairs
delete(key: string | number): void
- Delete key-value pairs
getServersByType(serverType: string): ServerInfo[]
- Get a certain type of server
getServerById(serverId: string): ServerInfo
- Get a server
route(serverType: string, routeFunc: (session: Session) => string): void
- Routing configuration
(frontend server call)
getSession(uid: number): Session
- Get client session by uid
(frontend server call)
getAllClients(): { [uid: number]: I_clientSocket }
- Get all clients of this server
(frontend server call)
sendMsgByUid(cmd: number, msg: any, uids: number[]): void
- Send a message to the client
(frontend server call)
sendAll(cmd: number, msg: any): void
- Send a message to all clients of this server
(frontend server call)
sendMsgByUidSid(cmd: number, msg: any, uidsid: { "uid": number, "sid": string }[]): void
- Send a message to the client
(backend server call)
sendMsgByGroup(cmd: number, msg: any, group: { [sid: string]: number[] }): void
- Send a message to the client
(backend server call)
configure(serverType: string, cb: () => void): void
- Configure server execution function
before(filter: { "before": (cmd: number, msg: any, session: Session, cb: (hasError?: boolean) => void) => void }): void
- Some front work before message processing
after(filter: { "after": (cmd: number, msg: any, session: Session, cb: () => void) => void }): void
- Some post work after message processing
globalBefore(filter: { "before": (info: { cmd: number, msg: Buffer }, session: Session, cb: (hasError?: boolean) => void) => void }): void
- Some processing of the message when it first reaches the gateway server
on(event: "onAddServer" | "onRemoveServer", cb: (serverInfo: ServerInfo) => void): void
- Monitor events (add server, remove server)
on(event: "onStartAll", cb: () => void): void
- Monitor events (All servers are successfully started)
interface ServerInfo {
/**
* Server id
*/
readonly "id": string;
/**
* host
*/
readonly "host": string;
/**
* port
*/
readonly "port": number;
/**
* Is it a frontend server
*/
readonly "frontend": boolean;
/**
* clientPort
*/
readonly "clientPort": number;
/**
* Server type [Note: Assigned by the framework]
*/
readonly "serverType": string;
[key: string]: any;
}