/**
 *   Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
 *
 *   @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
 *                   Wechaty Contributors <https://github.com/wechaty>.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
import WebSocket from 'ws';
import type * as PUPPET from '@juzi/wechaty-puppet';
import { StateSwitch } from 'state-switch';
import * as jsonRpcPeer from 'json-rpc-peer';
import type { MessageInterface } from './user-modules/mod.js';
import type { WechatyInterface } from './wechaty/mod.js';
export interface IoOptions {
    wechaty: WechatyInterface;
    token: string;
    apihost?: string;
    protocol?: string;
    servicePort?: number;
}
export declare const IO_EVENT_DICT: {
    botie: string;
    error: string;
    heartbeat: string;
    jsonrpc: string;
    login: string;
    logout: string;
    message: string;
    raw: string;
    reset: string;
    scan: string;
    shutdown: string;
    sys: string;
    update: string;
};
declare type IoEventName = keyof typeof IO_EVENT_DICT;
interface IoEventScan {
    name: 'scan';
    payload: PUPPET.payloads.EventScan;
}
interface IoEventJsonRpc {
    name: 'jsonrpc';
    payload: jsonRpcPeer.JsonRpcPayload;
}
interface IoEventAny {
    name: IoEventName;
    payload: any;
}
declare type IoEvent = IoEventScan | IoEventJsonRpc | IoEventAny;
export declare class Io {
    protected options: IoOptions;
    protected readonly id: string;
    protected readonly protocol: string;
    protected eventBuffer: IoEvent[];
    protected ws: undefined | WebSocket;
    protected readonly state: StateSwitch;
    protected reconnectTimer?: ReturnType<typeof setTimeout>;
    protected reconnectTimeout?: number;
    protected lifeTimer?: ReturnType<typeof setTimeout>;
    protected onMessage: undefined | Function;
    protected scanPayload?: PUPPET.payloads.EventScan;
    protected jsonRpc?: jsonRpcPeer.Peer;
    constructor(options: IoOptions);
    toString(): string;
    private connected;
    start(): Promise<void>;
    private initEventHook;
    private initWebSocket;
    private wsOnOpen;
    private wsOnMessage;
    private wsOnMessageAsync;
    private wsOnError;
    private wsOnClose;
    private reconnect;
    private send;
    stop(): Promise<void>;
    /**
     *
     * Prepare to be overwritten by server setting
     *
     */
    private ioMessage;
    protected syncMessage(m: MessageInterface): Promise<void>;
}
export {};
//# sourceMappingURL=io.d.ts.map