/// <reference types="node" />
import { IActionError, IActorCallRequest, IActorCallResponse, IInvokeOptions, IInvokeResult, IMultiTypeInstanceContainer, IRemote } from '@darlean/base';
import { IEnvelope } from './infra/envelope';
import { ITransport, ITransportEnvelope, ITransportFailure, ITransportSession } from './infra/transport';
export type ITransportActorCallRequest = IActorCallRequest;
export type ITransportActorCallResponse = IActorCallResponse;
export declare const TRANSPORT_ERROR_TRANSPORT_ERROR = "TRANSPORT_ERROR";
export declare const TRANSPORT_ERROR_TRANSPORT_CALL_TIMEOUT = "TRANSPORT_CALL_TIMEOUT";
export declare const TRANSPORT_ERROR_TRANSPORT_CALL_INTERRUPTED = "TRANSPORT_CALL_INTERRUPTED";
export declare const TRANSPORT_ERROR_PARAMETER_MESSAGE = "Message";
interface IRemotePendingCall {
    resolve: (value: IInvokeResult) => void;
    reject: (error: unknown) => void;
    timeout: NodeJS.Timeout;
}
export interface IRemoteCallEnvelope extends IEnvelope {
    remoteCallKind: 'call' | 'return';
    remoteCallId: string;
}
export declare class TransportRemote implements IRemote {
    protected transport: ITransport;
    protected session?: ITransportSession;
    protected appId: string;
    protected pendingCalls: Map<string, IRemotePendingCall>;
    protected instanceContainer: IMultiTypeInstanceContainer;
    /**
     * Creates a new TransportRemote.
     * @param appId The id of the current application with which the remote makes itself known to the transport
     * @param transport The transport mechanism used to send/receive messages
     * @param container The multi-type instance container that this remote can dispatch incoming action requests to
     */
    constructor(appId: string, transport: ITransport, container: IMultiTypeInstanceContainer);
    init(): Promise<void>;
    finalize(): Promise<void>;
    invoke(options: IInvokeOptions): Promise<IInvokeResult>;
    protected invokeImpl(options: IInvokeOptions): Promise<IInvokeResult>;
    protected makeReturnEnvelope(callId: string): ITransportEnvelope;
    protected toTransportRequest(content: IActorCallRequest): ITransportActorCallRequest;
    protected fromTransportRequest(content: ITransportActorCallRequest): IActorCallRequest;
    protected toTransportResponse(content: IActorCallResponse): ITransportActorCallResponse;
    protected errorToTransportError(error: IActionError): IActionError;
    protected fromTransportResponse(content: ITransportActorCallResponse): IActorCallResponse;
    protected handleMessage(envelope: ITransportEnvelope, contents: unknown, failure?: ITransportFailure): void;
}
export {};
