-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.ts
More file actions
36 lines (24 loc) · 788 Bytes
/
common.ts
File metadata and controls
36 lines (24 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { AnyFunction, TCallback } from "./index.types";
export abstract class Common {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected abstract socket: any;
/** Contains instance of Socket */
abstract emit<TReq>(event: string, payload: TReq, ack?: AnyFunction): void;
abstract on<TRes>(event: string, callback: TCallback<TRes>): void;
abstract once<TRes>(event: string, callback: TCallback<TRes>): void;
abstract off(event: string): void;
abstract connected: boolean;
get disconnected() {
return !this.connected;
}
get instance() {
return this.socket;
}
abstract of(nsp: string): Common;
public connect(opts?: object) {
this.socket.connect(opts);
}
public disconnect() {
this.socket.disconnect();
}
}