import { GraphAPIResponse } from './constants.js';
import EventEmitter from 'events';

declare enum EventAck {
    SUCCESS = "SUCCESS",
    LATER = "LATER"
}
interface EventAckData {
    status: EventAck;
    message?: string;
}
interface DWClientConfig {
    clientId: string;
    clientSecret: string;
    keepAlive?: boolean;
    debug?: boolean;
    ua?: string;
    endpoint?: string;
    access_token?: string;
    autoReconnect?: boolean;
    subscriptions: Array<{
        type: string;
        topic: string;
    }>;
}
interface DWClientDownStream {
    specVersion: string;
    type: string;
    headers: {
        appId: string;
        connectionId: string;
        contentType: string;
        messageId: string;
        time: string;
        topic: string;
        eventType?: string;
        eventBornTime?: string;
        eventId?: string;
        eventCorpId?: string;
        eventUnifiedAppId?: string;
    };
    data: string;
}
interface OnEventReceived {
    (msg: DWClientDownStream): EventAckData;
}
declare class DWClient extends EventEmitter {
    debug: boolean;
    connected: boolean;
    registered: boolean;
    reconnecting: boolean;
    private userDisconnect;
    private reconnectInterval;
    private heartbeat_interval;
    private heartbeatIntervallId?;
    private sslopts;
    readonly config: DWClientConfig;
    private socket?;
    private dw_url?;
    private isAlive;
    private onEventReceived;
    constructor(opts: {
        clientId: string;
        clientSecret: string;
        ua?: string;
        keepAlive?: boolean;
        debug?: boolean;
    });
    getConfig(): {
        clientId: string;
        clientSecret: string;
        keepAlive?: boolean | undefined;
        debug?: boolean | undefined;
        ua?: string | undefined;
        endpoint?: string | undefined;
        access_token?: string | undefined;
        autoReconnect?: boolean | undefined;
        subscriptions: {
            type: string;
            topic: string;
        }[];
    };
    printDebug(msg: object | string): void;
    registerAllEventListener(onEventReceived: (v: DWClientDownStream) => EventAckData): this;
    registerCallbackListener(eventId: string, callback: (v: DWClientDownStream) => void): this;
    getAccessToken(): Promise<any>;
    getEndpoint(): Promise<this>;
    _connect(): Promise<void>;
    connect(): Promise<void>;
    disconnect(): void;
    heartbeat(): void;
    onDownStream(data: string): void;
    onSystem(downstream: DWClientDownStream): void;
    onEvent(message: DWClientDownStream): void;
    onCallback(message: DWClientDownStream): void;
    send(messageId: string, value: any): void;
    /**
     * 消息响应，避免服务端重试.
     * stream模式下，服务端推送消息到client后，会监听client响应，如果消息长时间未响应会在一定时间内(60s)重试推消息，可以通过此方法返回消息响应，避免多次接收服务端消息。
     * @param messageId
     * @param result
     * @returns
     * @memberof DWClient
     * @example
     * ```javascript
     * client.socketResponse(res.headers.messageId, result.data);
     * ```
     */
    socketCallBackResponse(messageId: string, result: any): void;
    sendGraphAPIResponse(messageId: string, value: GraphAPIResponse): void;
}

export { DWClient, type DWClientConfig, type DWClientDownStream, EventAck, type EventAckData, type OnEventReceived };
