import type { ConnectionOptions } from '../../types'; import type { StreamingTransportInterface, StateChangeCallback, ReceiveCallback } from '../types'; declare const STATE_NONE = 0; declare const STATE_AWAITING_START = 1; declare const STATE_CONNECTING = 2; declare const STATE_CONNECTED = 3; declare const STATE_AWAITING_NEW_TOKEN_TO_RECONNECT = 4; declare type WS_STATE = typeof STATE_NONE | typeof STATE_AWAITING_START | typeof STATE_CONNECTING | typeof STATE_CONNECTED | typeof STATE_AWAITING_NEW_TOKEN_TO_RECONNECT; /** * Simple unidirectional (receive) WebSocket transport. * Follows WebSocket behaviour defined by spec: * https://html.spec.whatwg.org/multipage/web-sockets.html * * Supports simple reconnect mechanism in scenarios when webSocket will be closed. * * @param baseUrl - The base url. * @param restTransport - The Rest Transport. * @param failCallback - The Fail callback. If invoked, indicates that something went * critically wrong and this transport cannot be used anymore. */ declare class WebsocketTransport implements StreamingTransportInterface { name: "plainWebSockets"; socket: WebSocket | null; connectionUrl: string; authorizeUrl: string; hasBeenConnected: boolean; lastMessageId: null | number; reconnectTimeout: number | null; reconnectCount: number; lastOrphanFound: number; lastSubscribeNetworkError: number; lastMessageTime: number; query: string | null; contextId: string | null; isAuthorized: boolean; authToken: string | null; failCallback: (data?: { message: string; }) => void; stateChangedCallback: StateChangeCallback; receivedCallback: ReceiveCallback; connectionSlowCallback: () => void; startedCallback: () => void; unauthorizedCallback: (url: string) => void; utf8Decoder: TextDecoder; inactivityFinderRunning: boolean; inactivityFinderNextUpdateTimeoutId: number | null; state: WS_STATE; constructor(baseUrl: string, failCallback?: (data?: { message: string; }) => void); static isSupported(): boolean; private normalizeWebSocketUrl; private handleSocketOpen; private parseMessage; private handleSocketMessage; private handleSocketClose; private createSocket; private reconnect; private restartConnection; private destroySocket; /** * Handle transport failure. */ private handleFailure; private detectNetworkError; private startInactivityFinder; private stopInactivityFinder; private onInactivityFinderUpdate; isSupported: typeof WebsocketTransport.isSupported; setUnauthorizedCallback(callback: (url: string) => void): void; setStateChangedCallback(callback: StateChangeCallback): void; setReceivedCallback(callback: ReceiveCallback): void; setConnectionSlowCallback(callback: () => void): void; authorizeConnection(contextId: string | null, authToken: string | null, forceAuthenticate?: boolean): void; start(_options?: ConnectionOptions, callback?: () => void): void; onAuthorized(): void; onAuthorizedAwaitingStart(): void; onAuthorizedAwaitingReconnect(): void; stop(): void; onOrphanFound(): void; onSubscribeNetworkError(): void; updateQuery(authToken: string, contextId: string, _authExpiry?: number, forceAuth?: boolean): void; getQuery(): string | null; } export default WebsocketTransport;