import { SseData } from '../types/entity'; import type { ConnectionClosedPayload } from '../types/entity'; interface SseOptions { url: string; token: string; retryInterval?: number; connectTimeout?: number; maxRetries?: number; debug?: boolean; onMessage?: (response: SseData) => void; onReconnectSuccess?: () => void; onConnectionClosed?: (payload: ConnectionClosedPayload) => void; onMaxRetriesReached?: () => void; onConnectionChange?: (isConnected: 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?; private onMaxRetriesReachedCallback?; private onConnectionChangeCallback?; private isDestroyed; private debug; constructor(options: SseOptions); private debugLog; private debugError; private debugWarn; private removeAllEventListeners; private _openHandler; private _errorHandler; private _messageHandler; private _customHandlers; private connectTimeoutRef; subscribe(type: string, handler: Function): void; connect(): Promise; private notifyConnectionClosed; private handleReconnect; private cleanup; unsubscribe(): void; destroySse(): void; close(): void; isConnected(): boolean; /** * 发送消息到服务器 * SSE 是单向通信协议,不支持客户端向服务器发送消息 * @param data 要发送的数据 * @throws Error 总是抛出错误,因为 SSE 不支持发送 * @returns 永远不会返回(总是抛出错误) */ send(data: string | object | ArrayBuffer | Blob | ArrayBufferView): boolean; } export default SseClient;