/** * WebSocket消息协议类型定义 */ /** * 消息类型枚举 */ export declare enum EMessageType { /** HTTP请求消息 */ REQUEST = "REQUEST", /** HTTP响应消息 */ RESPONSE = "RESPONSE", /** 心跳ping消息 */ HEARTBEAT_PING = "HEARTBEAT_PING", /** 心跳pong消息 */ HEARTBEAT_PONG = "HEARTBEAT_PONG", /** 认证消息 */ AUTH = "AUTH", /** 认证成功响应 */ AUTH_SUCCESS = "AUTH_SUCCESS", /** 认证失败响应 */ AUTH_FAILED = "AUTH_FAILED", /** 错误消息 */ ERROR = "ERROR" } /** * HTTP请求消息 */ export interface IRequestMessage { type: EMessageType.REQUEST; requestId: string; method: string; url: string; params?: Record; headers?: Record; body?: any; timestamp: number; } /** * HTTP响应消息 */ export interface IResponseMessage { type: EMessageType.RESPONSE; requestId: string; status: number; headers: Record; body?: any; timestamp: number; } /** * 心跳Ping消息 */ export interface IHeartbeatPingMessage { type: EMessageType.HEARTBEAT_PING; timestamp: number; } /** * 心跳Pong消息 */ export interface IHeartbeatPongMessage { type: EMessageType.HEARTBEAT_PONG; timestamp: number; } /** * 认证消息 */ export interface IAuthMessage { type: EMessageType.AUTH; token: string; clientId: string; timestamp: number; } /** * 认证成功消息 */ export interface IAuthSuccessMessage { type: EMessageType.AUTH_SUCCESS; message: string; timestamp: number; } /** * 认证失败消息 */ export interface IAuthFailedMessage { type: EMessageType.AUTH_FAILED; message: string; timestamp: number; } /** * 错误消息 */ export interface IErrorMessage { type: EMessageType.ERROR; requestId?: string; code: string; message: string; timestamp: number; } /** * WebSocket消息联合类型 */ export type TWebSocketMessage = IRequestMessage | IResponseMessage | IHeartbeatPingMessage | IHeartbeatPongMessage | IAuthMessage | IAuthSuccessMessage | IAuthFailedMessage | IErrorMessage; /** * 待处理的请求项 */ export interface IPendingRequest { requestId: string; resolve: (response: IResponseMessage) => void; reject: (error: Error) => void; timer: NodeJS.Timeout; timestamp: number; } //# sourceMappingURL=protocol.d.ts.map