forked from ClusterWS/cWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
96 lines (89 loc) · 3.11 KB
/
index.d.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Generated by dts-bundle v0.7.3
// Dependencies for this module:
// ../../../http
// ../../../net
// ../../../https
import * as HTTP from 'http';
import { Socket } from 'net';
import * as HTTPS from 'https';
export const EventEmitterClient: any;
export class WebSocket extends EventEmitterClient {
OPEN: number;
CLOSED: number;
external: any;
executeOn: string;
constructor(url: string, external?: any, isServer?: boolean);
readonly _socket: SocketAddress;
readonly remoteAddress: string;
readonly readyState: number;
onopen: Listener;
onclose: Listener;
onerror: Listener;
onmessage: Listener;
on(event: string, listener: Listener): void;
on(event: 'open', listener: () => {}): void;
on(event: 'error', listener: (err: Error) => void): void;
on(event: 'message', listener: (message: string | any[]) => void): void;
on(event: 'close', listener: (code?: number, reason?: string) => void): void;
ping(message?: string | Buffer): void;
send(message: string | Buffer, options?: SendOptions, cb?: Listener): void;
terminate(): void;
close(code?: number, reason?: string): void;
}
export const EventEmitterServer: any;
export class WebSocketServer extends EventEmitterServer {
constructor(configs: ServerConfigs, callback?: Listener);
on(event: string, listener: Listener): void;
on(event: 'error', listener: (err: Error, socket?: Socket) => void): void;
on(event: 'connection', listener: (socket: WebSocket, upgradeRequest: HTTP.IncomingMessage) => void): void;
on(event: 'connection', listener: (socket: WebSocket) => void): void;
broadcast(message: string | Buffer, options?: BroadcastOptions): void;
startAutoPing(interval: number, appLevel?: boolean): void;
close(callback?: Listener): void;
}
export const native: any;
export const OPCODE_TEXT: number;
export const OPCODE_PING: number;
export const OPCODE_BINARY: number;
export const APP_PING_CODE: Buffer;
export const PERMESSAGE_DEFLATE: number;
export const SLIDING_DEFLATE_WINDOW: number;
export const DEFAULT_PAYLOAD_LIMIT: number;
export const noop: any;
export class EventEmitter {
on(event: string, listener: Listener): void;
emit(event: string, ...args: any[]): void;
removeEvents(): void;
}
export function eventEmitter(): any;
export type Listener = (...args: any[]) => void;
export type SocketAddress = {
remotePort: number | string | null;
remoteAddress: string | null;
remoteFamily: string | null;
};
export type ConnectionInfo = {
req: HTTP.IncomingMessage;
origin: string;
secure: boolean;
};
export type BroadcastOptions = {
binary?: boolean;
};
export type VerifyClientNext = (clientVerified: boolean, code?: number, name?: string) => void;
export type ServerConfigs = {
path?: string;
port?: number;
host?: string;
server?: HTTP.Server | HTTPS.Server;
noDelay?: boolean;
maxPayload?: number;
perMessageDeflate?: {
serverNoContextTakeover: boolean;
};
verifyClient?: (info: ConnectionInfo, next: VerifyClientNext) => void;
};
export type SendOptions = {
binary?: boolean;
compress?: boolean;
};