/// <reference types="node" />
import * as net from "net";
import { CmdData, Package } from './Dto';
export declare type Options = {
    serverIp: string;
    serverPort: number;
    reconnectDelay?: number;
};
export interface SocketClient {
    on(event: "connect", listener: () => void): this;
    on(event: "data", listener: (data: Buffer) => void): this;
    /**
     * 收到数据后，解码成功时触发
     * @param event
     * @param listener
     */
    on(event: "package", listener: (pack: Package) => void): this;
    /**
     * 收到数据后，解码成功且指令为n指令时触发
     * @param event
     * @param listener
     */
    on(event: "cmd", listener: (data: CmdData) => void): this;
    /**
     * 调用send方法后，在发送数据时(socket.write)触发
     * @param event
     * @param listener
     */
    on(event: "send", listener: (data: Buffer, cmd: string) => void): this;
    on(event: "error", listener: (err: Error) => void): this;
    on(event: "close", listener: (hadError: boolean) => void): this;
}
/**
 * 接收数据转义
 * @param data
 * @returns
 */
export declare function receive_escape(data: number[]): number[];
/**
 * 发送数据转义
 * @param data
 * @returns
 */
export declare function send_escape(data: Buffer): number[];
/**
 * 解码（反序列化）
 * @param datas
 * @returns
 */
export declare function decode(datas: Buffer[]): {
    packs: Package[];
    /**
     * 剩余未解码
     */
    left?: Buffer[];
};
/**
 * 编码（序列化）
 * @param cmd
 * @param data
 * @returns
 */
export declare function encode(cmd: string, data: Buffer): Buffer[];
/**
 * 视频服务程序SOCKET客户端
 */
export declare class SocketClient {
    private socket;
    readonly opts: Options;
    private emitter;
    private decode_cache;
    private disposed;
    private heartbeatTimer?;
    constructor(opts: Options);
    getSocketInstance(): net.Socket;
    /**
     * @param cmd 'A' | 'C' | 'D' | 'F' | 'n' | 'Z' | 'P' | 'V' 等
     * @param data
     */
    send(cmd: string, data: Buffer | object): void;
    destroy(): void;
    private _connect;
    private _reconnect;
    private _heartbeat;
    private _decode;
    private _send;
    private _dispose;
}
