-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatch.d.ts
More file actions
78 lines (63 loc) · 1.51 KB
/
Dispatch.d.ts
File metadata and controls
78 lines (63 loc) · 1.51 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import type * as WebSocket from 'ws'
import type { Endpoint } from './Endpoint.js'
import type { Protocol } from './Endpoint.js'
import type { Aux_Base } from './Endpoint.js'
export type Protocol_Core_Dispatch =
{
'@listening': void,
}
export type Protocol_All <In>
= (In & Protocol_Core_Dispatch)
export type Room
<
In extends Protocol = Protocol,
Out extends Protocol = Protocol,
Aux extends Aux_Base = Aux_Base,
>
=
{
join (endp: Endpoint<In, Out, Aux>): void;
leave (endp: Endpoint<In, Out, Aux>): void;
has (endp: Endpoint<In, Out, Aux>): boolean;
send: Endpoint<In, Out, Aux>['send'],
each (fn: (endp: Endpoint<In, Out, Aux>) => void): void;
}
export type Rooms
<
In extends Protocol = Protocol,
Out extends Protocol = Protocol,
Aux extends Aux_Base = Aux_Base,
>
=
{
get (name: string): Room<In, Out, Aux>;
list (): string[];
has (name: string): boolean;
remove (name: string): void;
send: Endpoint<In, Out, Aux>['send'],
join_if_any (name: string, endp: Endpoint<In, Out, Aux>): void;
leave_every (endp: Endpoint<In, Out, Aux>): void;
}
export type Dispatch
<
In extends Protocol = Protocol,
Out extends Protocol = Protocol,
Aux extends Aux_Base = Aux_Base,
>
=
{
on: Endpoint<Protocol_All<In>, Out, Aux>['on'];
close (): void;
rooms: Rooms<Protocol_All<In>, Out, Aux>;
}
export default function Dispatch
<
In extends Protocol = Protocol,
Out extends Protocol = Protocol,
Aux extends Aux_Base = Aux_Base,
>
(
wss: WebSocket.Server | WebSocket.ServerOptions
)
:
Dispatch<In, Out, Aux>