import { z } from 'zod'; import { Evt } from 'evt'; import type { DuplexMessage } from '../internalRpcSchema'; import ISocket from './ISocket'; export interface MethodDef { [key: string]: { inputs: z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion; returns: z.ZodFirstPartySchemaTypes | z.ZodDiscriminatedUnion; }; } declare type OnReplyFn = (anyObject: any) => void; export declare type DuplexRPCHandlers = { [Property in keyof ResponderSchema]: (inputs: z.infer) => Promise>; }; interface CreateDuplexRPCClientProps { communicator: ISocket; canCall: CallerSchema; canRespondTo: ResponderSchema; handlers: DuplexRPCHandlers; retryChunkIntervalMs?: number; } /** * Responsible for making RPC calls to another DuplexRPCClient. * Can send messages from CallerSchema and respond to messages * from ResponderSchema. * * @property communicator - The ISocket instance responsible for * sending the RPC messages. * @property handlers - Defines the actions taken when receiving * a given message, an object keyed by the message schema key. */ export declare class DuplexRPCClient { #private; communicator: ISocket; canCall: CallerSchema; canRespondTo: ResponderSchema; handlers: { [Property in keyof ResponderSchema]: (inputs: z.infer) => Promise>; }; pendingCalls: Map; messageChunks: Map; onMessageReceived: Evt; constructor({ communicator, canCall, canRespondTo, handlers, retryChunkIntervalMs, }: CreateDuplexRPCClientProps); private packageResponse; private packageCall; setCommunicator(newCommunicator: ISocket): void; private handleReceivedResponse; private handleReceivedCall; private onmessage; send(methodName: MethodName, inputs: z.input, options?: { timeoutFactor?: number; }): Promise>; } export {};