import { P2PErrorHandler, P2PHandler, P2PProvider } from "./Provider.js";
import { NetMessage } from "./Types.js";
type SetTimeout = (handler: any, timeout: number, ...args: any[]) => number;
export interface P2PClientOptions {
    /** P2P provider to use  */
    provider: P2PProvider;
    /** heartbeat timout in milliseconds, or undefined if no heartbeat is desired */
    heartbeatTimoutMs?: number;
    /** alternative implementation for setTimeout (mostly for testing) */
    setTimeoutImpl?: SetTimeout;
}
/**
 * @argument message a decoded message from the lower transport layer
 */
export type P2PMessageHandler = (message: NetMessage) => void;
type P2PClientEventMap = {
    message: P2PMessageHandler;
    error: P2PErrorHandler;
    close: P2PHandler;
};
export declare class P2PClient {
    static __className: string;
    readonly provider: P2PProvider;
    private setTimeoutImpl;
    private heartbeatTimoutMs?;
    private heartbeatTimoutId?;
    private eventListeners;
    constructor(options: P2PClientOptions);
    send(message: NetMessage["value"], done?: P2PHandler): void;
    end(cb?: P2PHandler): void;
    destroy(err?: Error): void;
    private handleData;
    private endHeartbeat;
    private resetHeartbeat;
    private handleHeartbeat;
    on<T extends keyof P2PClientEventMap>(event: T, handler: P2PClientEventMap[T]): this;
    once<T extends keyof P2PClientEventMap>(event: T, handler: P2PClientEventMap[T]): this;
    addListener<T extends keyof P2PClientEventMap>(event: T, handler: P2PClientEventMap[T]): this;
    prependListener<T extends keyof P2PClientEventMap>(event: T, handler: P2PClientEventMap[T]): this;
    removeListener<T extends keyof P2PClientEventMap>(event: T, handler: P2PClientEventMap[T]): this;
    private addListenerInternal;
    private emit;
}
export {};
//# sourceMappingURL=Client.d.ts.map