/// <reference types="node" />
/// <reference types="node" />
import http from 'http';
import https from 'https';
import { MessageConnection } from './MessageConnection';
export type ConnectionId = string;
type ConnectHandler<T, R, A = never> = (conn: MessageConnection<T, R, A>, upgradeRequest: http.IncomingMessage) => Promise<void>;
type DisconnectHandler<T, R, A = never> = (conn: MessageConnection<T, R, A>) => Promise<void>;
type ReceiveHandler<T, R, A = never> = (conn: MessageConnection<T, R, A>, message: T) => Promise<R | AsyncIterableIterator<R>>;
interface Config {
    httpServer: http.Server | https.Server;
    path?: string;
}
export declare class WebSocketMessageServer<T = unknown, R = T, A = never> {
    private wss;
    onConnect: ConnectHandler<T, R, A>;
    onDisconnect: DisconnectHandler<T, R, A>;
    onReceive: ReceiveHandler<T, R, A>;
    private connectionsById;
    constructor({ httpServer, path }: Config);
    getConnection(id: ConnectionId): MessageConnection<T, R, A> | undefined;
    get connections(): MessageConnection<T, R, A>[];
    close(): Promise<void>;
    private start;
}
export {};
