UNPKG

sim-sdk-web

Version:

Sim SDK for Web

44 lines (43 loc) 1.24 kB
import { SseData } from '../types/entity'; interface SseOptions { url: string; token: string; retryInterval?: number; connectTimeout?: number; maxRetries?: number; onMessage?: (response: SseData) => void; onReconnectSuccess?: () => void; onConnectionClosed?: (isAuthError: boolean) => void; } declare class SseClient { private url; private token; private eventSource; private reconnectAttempts; private maxReconnectAttempts; private reconnectTimeout; private connectTimeout; private reconnectTimer; private handlers; private connected; private onMessageCallback?; private onReconnectSuccessCallback?; private onConnectionClosedCallback?; constructor(options: SseOptions); private removeAllEventListeners; private _openHandler; private _errorHandler; private _messageHandler; private _customHandlers; private connectTimeoutRef; subscribe(type: string, handler: Function): void; connect(): Promise<string>; private notifyConnectionClosed; private handleReconnect; private cleanup; unsubscribe(): void; destroySse(): void; close(): void; isConnected(): boolean; } export default SseClient;