From a1a7755d2a98a072b606dd1f2b51a970cc433402 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 4 May 2018 14:00:33 -0700 Subject: [PATCH] Add type definitions for w3cwebsocket in the websocket package (#25355) --- types/websocket/index.d.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/types/websocket/index.d.ts b/types/websocket/index.d.ts index 0087c7a3d1..cd17039b1c 100644 --- a/types/websocket/index.d.ts +++ b/types/websocket/index.d.ts @@ -670,6 +670,35 @@ declare class router extends events.EventEmitter { } +declare class w3cwebsocket { + static CONNECTING: number; + static OPEN: number; + static CLOSING: number; + static CLOSED: number; + + url: string; + readyState: number; + protocol?: string; + extenstions: IExtension[]; + bufferedAmount: number; + + CONNECTING: number; + OPEN: number; + CLOSING: number; + CLOSED: number; + + onopen: () => void; + onerror: (error: Error) => void; + onclose: () => void; + onmessage: (message: any) => void; + + constructor(url: string, protocols?: string[], origin?: string, headers?: any[], requestOptions?: object, clientConfig?: IClientConfig); + + send(data: Buffer): void; + send(data: IStringified): void; + close(code?: number, reason?: string): void; +} + export declare var version: string; export declare var constants: { DEBUG: boolean;