/** * @file datachannel-manager.ts * @description Bridges SCTP streams + DCEP to RTCDataChannel instances. * @module sctp/datachannel-manager * * Responsibilities: * - Allocate SCTP stream IDs per RFC 8832 ยง6: the DTLS client (a=setup:active) * uses even stream IDs, the DTLS server uses odd. * - Send DATA_CHANNEL_OPEN and await DATA_CHANNEL_ACK; respond to inbound OPEN. * - Map outgoing string/binary sends to the correct PPID, and incoming PPIDs * back to string/binary, including the EMPTY variants for zero-length data. */ import { EventEmitter } from 'events'; import type { SctpAssociation } from './association'; import { RTCDataChannel } from '../datachannel/RTCDataChannel'; /** Subset of RTCDataChannelInit used when opening/accepting channels. */ interface ChannelInit { ordered?: boolean; maxRetransmits?: number | null; maxPacketLifeTime?: number | null; protocol?: string; } /** Information surfaced on the 'open-request' event for an inbound channel. */ export interface OpenRequestInfo { streamId: number; label: string; protocol: string; ordered: boolean; channelType: number; reliabilityParameter: number; } declare class DataChannelManager extends EventEmitter { #private; /** * @param {import('./association').SctpAssociation} association * @param {boolean} isDtlsClient - true if we are the DTLS client (even IDs) */ constructor(association: SctpAssociation, isDtlsClient: boolean); /** * Open a channel initiated locally. * @param {import('../datachannel/RTCDataChannel').RTCDataChannel} channel * @param {Object} init - { ordered, maxRetransmits, maxPacketLifeTime, protocol } */ openChannel(channel: RTCDataChannel, init?: ChannelInit): void; /** Tear down the manager: detach the SCTP listener and drop all channels. */ close(): void; /** * Register an inbound channel (created in response to 'open-request') and * attach its sender. */ acceptChannel(channel: RTCDataChannel, info: OpenRequestInfo): void; } export { DataChannelManager };