/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format * @flow */ import { WebSocketEvent } from './common'; import { WebSocketPolyfill } from './websocket.definition'; type ArrayBufferView = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | DataView; type BinaryType = 'blob' | 'arraybuffer'; /** * Browser-compatible WebSockets implementation. * * See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket * See https://github.com/websockets/ws */ export declare class WebSocket implements WebSocketPolyfill { private nativeBridge; static CONNECTING: number; static OPEN: number; static CLOSING: number; static CLOSED: number; static HANDLE_THREADING: boolean; CONNECTING: number; OPEN: number; CLOSING: number; CLOSED: number; _binaryType: BinaryType; onclose?: Function; onerror?: Function; onmessage?: Function; onopen?: Function; bufferedAmount?: number; extension?: string; protocol?: string; readyState: number; url: string; private listeners; constructor(url: string, protocols?: string | Array, options?: { headers: { origin?: string; [key: string]: unknown; }; nativescript: { handleThreading: boolean; }; [key: string]: unknown; }); addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void; get binaryType(): BinaryType; set binaryType(binaryType: BinaryType); close(code?: number, reason?: string): void; send(data: string | ArrayBuffer | ArrayBufferView | Blob): void; ping(): void; dispatchEvent(event: WebSocketEvent): void; _close(code?: number, reason?: string): void; _unregisterEvents(): void; _websocketOpen(protocol: string): void; _websocketClosed(code: number, reason: string, wasClean: boolean): void; _websocketMessage(message: string | ArrayBuffer | ArrayBufferView | Blob): void; _websocketFailed(error: string): void; _registerEvents(): void; } export {};