25 lines
911 B
TypeScript
25 lines
911 B
TypeScript
declare module "ws" {
|
|
export type RawData = Buffer | ArrayBuffer | Buffer[] | string;
|
|
|
|
export class WebSocket {
|
|
static readonly OPEN: number;
|
|
constructor(url: string);
|
|
readonly readyState: number;
|
|
send(data: string): void;
|
|
close(code?: number, reason?: string): void;
|
|
terminate(): void;
|
|
on(event: "open", listener: () => void): this;
|
|
on(event: "message", listener: (data: RawData) => void): this;
|
|
on(event: "close", listener: (code: number, reason: Buffer) => void): this;
|
|
on(event: "error", listener: (error: Error) => void): this;
|
|
once(event: "open", listener: () => void): this;
|
|
once(event: "error", listener: (error: Error) => void): this;
|
|
off(event: "error", listener: (error: Error) => void): this;
|
|
removeAllListeners?(event?: string): this;
|
|
}
|
|
|
|
export class WebSocketServer {
|
|
constructor(options: { host?: string; port: number });
|
|
}
|
|
}
|