Merge pull request #8 from jhalitaksoy/feature/isClientOnline

add isClientOnline
This commit is contained in:
Halit Aksoy 2022-07-16 19:01:13 +03:00 committed by GitHub
commit f248d8333a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -1,7 +1,8 @@
export type Bytes = Buffer 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;
}
} }