UNPKG

askexperts

Version:

AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol

42 lines (41 loc) 1.06 kB
/** * Browser implementation of WebSocket */ export interface ClientOptions { headers?: Record<string, string>; } /** * WebSocket wrapper for browser environments * This provides a compatible interface with the 'ws' package */ export declare class WebSocket { private socket; private eventHandlers; /** * Create a new WebSocket * @param url - WebSocket URL to connect to * @param options - Connection options */ constructor(url: string, options?: ClientOptions); /** * Register an event handler * @param event - Event name * @param callback - Event handler function */ on(event: string, callback: Function): void; /** * Trigger an event * @param event - Event name * @param args - Event arguments */ private triggerEvent; /** * Send data through the WebSocket * @param data - Data to send */ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void; /** * Close the WebSocket connection */ close(): void; }