@arifwidianto/rpc-agent
Version:
RPC Agent for both client and server, extends more methods easily
36 lines (35 loc) • 1.58 kB
TypeScript
import { RpcClientConfig } from "./interfaces";
import { AgentExtensionStatus, AgentPortValidationResult, AgentSystemInfo, AgentDateInfo, AgentEchoResponse } from "./interfaces";
export declare class RpcClient {
private availableExtensions;
private tcpClient;
private udpClient;
private requestId;
private isClosing;
private reconnectAttempts;
private maxReconnectAttempts;
private reconnectDelay;
private pendingRequests;
protected readonly config: RpcClientConfig;
protected readonly debug: boolean;
constructor(config: RpcClientConfig, debug?: boolean);
protected log(...args: unknown[]): void;
init(): Promise<void>;
close(): Promise<void>;
protected initializeTcpClient(): Promise<void>;
protected initializeUdpClient(): Promise<void>;
private handleUdpResponse;
private handleConnectionError;
private handleTcpResponse;
send<T>(method: string, params: Record<string, unknown>): Promise<T>;
protected sendTcpRequest<T>(method: string, params: Record<string, unknown>): Promise<T>;
protected sendUdpRequest<T>(method: string, params: Record<string, unknown>): Promise<T>;
}
export declare class AgentLibrary extends RpcClient {
constructor(config: RpcClientConfig, debug?: boolean);
getServerInfo(): Promise<AgentSystemInfo>;
listExtensions(): Promise<AgentExtensionStatus[]>;
validatePort(port: number, type: "TCP" | "UDP"): Promise<AgentPortValidationResult>;
echo(message: string): Promise<AgentEchoResponse>;
getCurrentDate(): Promise<AgentDateInfo>;
}