UNPKG

react-native-fast-io

Version:

Modern IO for React Native, built on top of Nitro and Web standards

68 lines 2.41 kB
import { Event, EventTarget } from 'event-target-shim'; import { Blob } from './blob'; declare enum WebSocketReadyState { CONNECTING = 0, OPEN = 1, CLOSING = 2, CLOSED = 3 } /** * Events */ export type OpenEvent = Event; export declare class MessageEvent extends Event { readonly data: string | Blob | ArrayBuffer; constructor(data: string | Blob | ArrayBuffer); } export declare class ErrorEvent extends Event { readonly error: string; constructor(error: string); } export declare class CloseEvent extends Event { readonly code: number; readonly reason: string; constructor(code?: number, reason?: string); get wasClean(): void; } /** * https://websockets.spec.whatwg.org/#interface-definition */ export declare class WebSocket extends EventTarget implements EventTarget<{ open: OpenEvent; message: MessageEvent; error: ErrorEvent; close: CloseEvent; }> { #private; readonly CONNECTING = WebSocketReadyState.CONNECTING; readonly OPEN = WebSocketReadyState.OPEN; readonly CLOSING = WebSocketReadyState.CLOSING; readonly CLOSED = WebSocketReadyState.CLOSED; readonly url: string; binaryType: 'arraybuffer' | 'blob'; get readyState(): WebSocketReadyState; get bufferedAmount(): void; get extensions(): void; get protocol(): string; private readonly ws; constructor(url: string, protocols?: string | string[]); /** * https://websockets.spec.whatwg.org/#dom-websocket-send */ send(message: string | ArrayBuffer | ArrayBufferView | Blob): void; /** * https://websockets.spec.whatwg.org/#dom-websocket-close */ close(code?: number, reason?: string): void; ping(): void; get onopen(): EventTarget.CallbackFunction<this, Event<string>> | null; set onopen(value: EventTarget.CallbackFunction<this, Event<string>> | null); get onmessage(): EventTarget.CallbackFunction<this, Event<string>> | null; set onmessage(value: EventTarget.CallbackFunction<this, Event<string>> | null); get onerror(): EventTarget.CallbackFunction<this, Event<string>> | null; set onerror(value: EventTarget.CallbackFunction<this, Event<string>> | null); get onclose(): EventTarget.CallbackFunction<this, Event<string>> | null; set onclose(value: EventTarget.CallbackFunction<this, Event<string>> | null); } export {}; //# sourceMappingURL=ws.d.ts.map