import type { ClientTarget } from "../client-id.js"; import type { Transport, TransportConnectOptions } from "../transport/transport.js"; import { type AppInfo } from "../types.js"; export interface DeviceConnectionSubscriber { readonly id: number; send(message: unknown): void; close(cause?: unknown): void; } /** * Maintains a persistent connection to a single device:port through a real * transport. * * On first connect it performs the Initialize/Register handshake and caches * the {@link AppInfo}. After that, messages from the device are broadcast to * all subscribers, and messages from clients are forwarded to the device. */ export declare class DeviceConnection { #private; readonly key: string; readonly deviceId: string; readonly port: ClientTarget; /** Populated after a successful Initialize/Register handshake. */ appInfo: AppInfo | null; constructor(transport: Transport, options: TransportConnectOptions); /** * Opens the underlying transport connection. The caller should wrap this * in a try/catch — a failure means the device:port is unreachable. */ connect(): Promise; waitUntilRegistered(): Promise; addSubscriber(subscriber: DeviceConnectionSubscriber): void; removeSubscriber(id: number): void; get subscriberCount(): number; get isDisposed(): boolean; get transport(): Transport; get isPersistent(): boolean; send(message: unknown): Promise; dispose(): Promise; }