export enum ReadyState {
    Connecting = 0,
    Open = 1,
    Closing = 2,
    Closed = 3,
}

export interface Options {
    heartbeat?: boolean; // 是否启用心跳检测
    protocols?: string | string[];
    manual?: boolean; // 是否手动连接
}

export enum RequestCode {
    Heartbeat = 1000, // 心跳检测
    QuoteSubscribe = 2033, // 行情订阅
    OrderPayment = 3345, // 订单支付
    PaymentNotify = 9999, // 订单支付通知
}

export enum MessageType {
    Heartbeat, // 心跳检测
    Request, // 请求响应
    Push, // 消息推送
}

/**
 * WebSocket 消息包
 */
export interface Message {
    headers: {
        requestId: string;
        requestCode: RequestCode;
        messageType: MessageType;
        token?: string;
        version?: number;
        timestamp?: number;
    };
    data: unknown;
}

/**
 * 信息发送异步任务
 */
export interface AsyncTask {
    timeoutId: number;
    callback: (data: unknown) => void;
}