-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-client.ts
36 lines (35 loc) · 1.1 KB
/
example-client.ts
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 type { Socket as SocketBase } from "socket.io-client";
export namespace Root {
/** @desc The actual path of the Root namespace */
export const path = "/";
export interface Emission {
time: (currentIsoTime: string) => void;
chat: (
message: string,
extraInfo: {
/** the ID of author */
from: string;
},
) => void;
rooms: (roomIds: string[]) => void;
error: (name: string, message: string) => void;
}
export interface Actions {
chat: (message: string) => void;
ping:
| ((cb1: (literally: "pong", ...echo: unknown[]) => void) => void)
| ((
anything1: unknown,
cb2: (literally: "pong", ...echo: unknown[]) => void,
) => void)
| ((
anything1: unknown,
anything2: unknown,
cb3: (literally: "pong", ...echo: unknown[]) => void,
) => void);
subscribe: (...doesNotMatter: unknown[]) => void;
unsubscribe: (...doesNotMatter: unknown[]) => void;
}
/** @example const socket: Root.Socket = io(Root.path) */
export type Socket = SocketBase<Emission, Actions>;
}