import { Socket } from "./RPCSocketServer"; declare type rpcType = 'hook' | 'unhook' | 'call'; declare type visibility = 'public' | 'private'; export declare type Outcome = "Success" | "Error"; export declare class Response { message?: string | undefined; constructor(message?: string | undefined); } export declare class SuccessResponse extends Response { result: Outcome; constructor(message?: string); } export declare class ErrorResponse extends Response { result: Outcome; constructor(message?: string); } export declare class SubscriptionResponse extends SuccessResponse { uid: string; constructor(uid: string, message?: string); } export declare type UnhookFunction = (uid: string) => Promise; export declare type callbackFunction = (...args: any[]) => Promise; export declare type AsyncFunction = (...args: any[]) => Promise; export interface RPCExporter { name: string; exportRPCs(): socketioRPC[]; } declare type baseRPC = { type: rpcType; name: string; visibility: visibility; }; declare type hookRPC = baseRPC & { type: 'hook'; func: callbackFunction; unhook: UnhookFunction; }; declare type unhookRPC = baseRPC & { type: 'unhook'; func: UnhookFunction; }; declare type callRPC = baseRPC & { type: 'call'; func: (...args: any[]) => Promise; }; export declare type socketioRPC = callRPC | unhookRPC | hookRPC; export declare type baseInfo = { owner: string; argNames: string[]; }; declare type HookInfo = baseRPC & baseInfo & { type: 'hook'; generator: (socket: any) => callbackFunction; unhook: UnhookFunction; }; declare type UnhookInfo = baseRPC & baseInfo & { type: 'unhook'; func: UnhookFunction; }; declare type CallInfo = baseRPC & baseInfo & { type: 'call'; func: AsyncFunction; }; declare type RpcInfo = HookInfo | UnhookInfo | CallInfo; export declare type ExtendedRpcInfo = RpcInfo & { uniqueName: string; }; export declare const rpcToRpcinfo: (rpc: socketioRPC, owner: string) => RpcInfo; export declare const rpcHooker: (socket: Socket, owner: string, RPCs: socketioRPC[], makeUnique?: boolean) => ExtendedRpcInfo[]; declare type OnFunction = (type: 'error' | 'close', f: (e?: any) => void) => Socket; export declare type Socket = { port: number; hook: (rpcname: string, ...args: any[]) => Socket; unhook: (rpcname: string) => Socket; call: (rpcname: string, ...args: any[]) => Promise; fire: (rpcname: string, ...args: any[]) => Promise; on: OnFunction; destroy: () => void; close: () => void; }; export declare type RPCSocketConf = { connectionHandler: (socket: Socket) => void; errorHandler: (socket: Socket) => (error: any) => void; closeHandler: (socket: Socket) => () => void; }; export declare class RPCSocketServer { private port; private rpcExporters; private conf; private io; private wsServer; constructor(port: number, rpcExporters?: RPCExporter[], conf?: RPCSocketConf); private startWebsocket; protected initApis(socket: any): void; } export {};