/**
 * @license
 * Copyright 2025-2026 Open Home Foundation
 * SPDX-License-Identifier: Apache-2.0
 */
import { CommandMessage, ServerInfoMessage } from "./models/model.js";
/**
 * WebSocket interface that works with both browser WebSocket and Node.js ws library.
 */
export interface WebSocketLike {
    readyState: number;
    onopen: ((event: unknown) => void) | null;
    onclose: ((event: unknown) => void) | null;
    onerror: ((event: unknown) => void) | null;
    onmessage: ((event: {
        data: unknown;
    }) => void) | null;
    send(data: string): void;
    close(): void;
}
export type WebSocketFactory = (url: string) => WebSocketLike;
export declare class Connection {
    ws_server_url: string;
    serverInfo?: ServerInfoMessage;
    private socket?;
    private wsFactory;
    /**
     * Create a new connection.
     * @param ws_server_url WebSocket server URL
     * @param wsFactory Optional factory function to create WebSocket instances.
     *                  If not provided, uses the global WebSocket constructor.
     */
    constructor(ws_server_url: string, wsFactory?: WebSocketFactory);
    get connected(): boolean;
    connect(onMessage: (msg: unknown) => void, onConnectionLost: () => void): Promise<void>;
    disconnect(): void;
    sendMessage(message: CommandMessage): void;
}
export default Connection;
//# sourceMappingURL=connection.d.ts.map