import { Client } from '../base/Client'; import { JsonRpcRequest } from '../base/JsonRpcRequest'; import { WebSocketAddress, WebSocketAddressInitializer } from '../base/Transports'; interface WebSocketClientOptions { /** * Should logging of connection errors etc be done? */ logging: boolean; /** * Seconds to wait for connection to be open * before sending a message. */ timeout: number; /** * Number of attempts to reconnect if * the connection is closed. */ retries: number; } /** * A `Client` using the WebSockets API for communication. */ export declare class WebSocketClient extends Client { /** * The address of the server to connect to. */ readonly address: WebSocketAddress; /** * Options for this client. */ readonly options: WebSocketClientOptions; /** * The `WebSocket` instance used for connections. * * See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket for * properties and methods. */ private socket?; /** * Has this client been explicitly stopped. * * Used to determine whether to try to reconnect. */ private isStopped; /** * Is this client attempting to reestablish a connection */ isRetrying: boolean | undefined; /** * Construct a `WebSocketClient`. * * @param address The address of the server to connect to */ constructor(address?: WebSocketAddressInitializer, options?: Partial); private retryConnect; /** * Start the connection. * * Creates a new WebSocket and sets up event handlers including * for automatically reconnecting if the connection is closed. */ start(): Promise; /** * @implements Implements {@link Client.send} to send * the request using the Websocket * * @description Will wait until the socket is open before * attempting to send the data. */ protected send(request: JsonRpcRequest): Promise; /** * @override Override of {@link Client.receive} to only * accept messages if the WebSocket is open. */ protected receive(message: string): void; /** * Stop the connection by closing the WebSocket. */ stop(): Promise; /** * @implements Implements {@link ClientType.discover}. * * @description Not implemented yet. In the future * could be implemented using port scanning on the * localhost. */ static discover(): Promise; } export {};