-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
30 lines (28 loc) · 951 Bytes
/
index.d.ts
File metadata and controls
30 lines (28 loc) · 951 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
import type { Server } from 'node:http';
import type { Socket } from 'node:net';
export interface WebsocketServer {
getInfo: () => {
listening: boolean;
port: number;
clients: string[];
};
send: (keys: string[], message: string) => void;
broadcast: (message: string) => void;
close: () => void;
onError: (callback: (error: Error) => void) => void;
onBroadcast: (callback: (message: string) => void) => void;
onSend: (callback: (key: string, message: string) => void) => void;
onMessage: (callback: (key: string, message: string) => void) => void;
onConnection: (callback: (key: string) => void) => void;
onDisconnection: (callback: (key: string) => void) => void;
onListen: (callback: () => void) => void;
onClose: (callback: () => void) => void;
}
export interface Ws {
createWebSocketServer: (options: { port: number | string }) => WebsocketServer;
}
declare global {
interface Window {
ws: Ws;
}
}