import { Subject } from 'rxjs'; import { MessageClient } from '../message-client'; import { MessageResponse } from '../message-response.type'; import { Message } from '../message.interface'; import { GET_NEW_ID, RESPONSES$, SEND } from '../selectors'; import { RTCConnectionArg } from './rtc.type'; declare const CHANNEL_NAME: unique symbol; declare const CHANNEL: unique symbol; declare const CHANNEL_OPEN: unique symbol; declare const DEINITIALIZE: unique symbol; export declare const READY: unique symbol; export declare const CREATED: unique symbol; /** * WebRTC DataChannel message client that sends request messages and receives * responses over a negotiated channel. * * Both peers must create the channel with an identical name and negotiated ID. * The ID is derived automatically from the channel name via an FNV-1a hash * unless an explicit `channelId` is supplied. * * Use `@Request` decorators to define outgoing RPC methods. The client can be * constructed without a connection and initialized later via {@link initialize}. * * @example * ```typescript * class GameClient extends RTCMessageClient { * @Request('move') * sendMove(position: [number, number]): Observable { * return null!; * } * } * * const client = new GameClient(peerConnection, 'game-events'); * client.sendMove([3, 4]).subscribe(ok => console.log('Accepted:', ok)); * ``` */ export declare class RTCMessageClient extends MessageClient { [RESPONSES$]: Subject; private [CHANNEL_NAME]; private [CHANNEL]; private [CHANNEL_OPEN]; private [DEINITIALIZE]; private get [CREATED](); /** Resolves with the `RTCDataChannel` once it has been created (may not yet be open). */ get created(): Promise; private get [READY](); /** Resolves with the `RTCDataChannel` once it is open and ready to transmit. */ get ready(): Promise; /** * @param connection - RTCPeerConnection instance, promise, or factory function. Omit to initialize later via {@link initialize}. * @param channelName - Name for the negotiated data channel. Determines the channel ID via FNV-1a hash. * @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default. */ constructor(connection?: RTCConnectionArg, channelName?: string, channelId?: number); /** * (Re)initializes the data channel with a new connection. * Waits for the previous channel to be cleaned up (with a 5 s timeout) * before establishing the new one. * * @param connection - RTCPeerConnection instance, promise, or factory function. * @param channelId - Optional negotiated channel ID. Defaults to the hash-derived ID. */ initialize(connection?: RTCConnectionArg, channelId?: number): void; [SEND](message: Message): Promise; protected [GET_NEW_ID](): string; } export {};