add isClientOnline

This commit is contained in:
Halit Aksoy 2022-07-16 19:00:30 +03:00
parent dab02a247f
commit 1473994580
2 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,7 @@ export type Bytes = Buffer
export type OnMessage = (clientID: string, message: Object) => any export type OnMessage = (clientID: string, message: Object) => any
export interface RTMT { export interface RTMT {
sendMessage : (clientID : string, channel : string, message : Object) => any sendMessage: (clientID: string, channel: string, message: Object) => any;
listenMessage : (channel : string, callback : OnMessage) => any listenMessage: (channel: string, callback: OnMessage) => any;
isClientOnline(clientID: string): boolean;
} }

View File

@ -126,4 +126,10 @@ export class RTMTWS implements RTMT {
//@ts-ignore //@ts-ignore
ws.isAlive = true; ws.isAlive = true;
} }
isClientOnline(clientID: string): boolean {
const ws = this.clients.has(clientID);
//@ts-ignore
return ws && ws.isAlive;
}
} }