UNPKG

rpc-ws

Version:

JSON-RPC 2.0 implementation with websockets

27 lines (23 loc) 633 B
type SocketResponse<T = any> = { id?: number | null; jsonrpc: string; result?: T; notification?: string; params?: any; error?: { code: number; message: string; data?: any; }; }; type SocketSendOptions = { timeout?: number; }; declare function Client(endpoint: string, opts?: SocketSendOptions): Promise<{ subscribe: (namespace: string, cb: (params: any[]) => void) => Promise<SocketResponse>; unsubscribe: (namespace: string) => Promise<SocketResponse<any>>; close: () => void; } & { [k: string]: <T>(...args: any) => Promise<SocketResponse<T>>; }>; export { Client as BrowserClient };