import WebSocket = require("ws"); import { WebSocketStream } from "@hediet/typed-json-rpc-websocket"; import { EventSource } from "@hediet/std/events"; export interface StartWebSocketServerOptions { /** * The port to listen on. Use `undefined` to listen on a random port. * You can then use `WebSocketServer.port` to get the chosen port. */ port?: number | undefined; } /** * Starts a new web socket server. * Use `handleConnection` to handle the streams of incoming connections. */ export declare function startWebSocketServer(options: StartWebSocketServerOptions, handleConnection: (stream: WebSocketStream) => void): WebSocketServer; /** * Wraps a websocket server. */ export declare class WebSocketServer { private readonly server; constructor(server: WebSocket.Server); /** * Is resolved once the socket is listening. */ readonly onListening: Promise; readonly onError: EventSource; /** * Gets the port the websocket server is running on. */ readonly port: number; /** * Closes the server. */ close(): void; /** * Same as `close`. */ dispose(): void; } //# sourceMappingURL=index.d.ts.map