/** * @module DataChannels */ import { Subject, Subscription } from "rxjs"; import type { Bubble } from "./bubble.model"; import type { Contact } from "./contact.model"; import { RBEvent } from "./event.model"; import type { JingleSession } from "../libs/strophe/strophe.jingle.session"; import type { Branded } from "../utils/branded"; import type { User } from "./user.model"; import { EventableService } from "../services/service"; /** * DataChannel status */ export declare enum DataChannelStatus { DISCONNECTED = "disconnected", PROPOSED = "proposed", INVITED = "invited", REFUSED = "refused", CONNECTING = "connecting", CONNECTED = "connected", CLOSED = "closed" } /** * @eventProperty * `DataChannel` specific events * Can listen to it via `dataChannel.subscribe()` API */ export declare enum DataChannelEvents { /** * @eventProperty * This `RBEvent` is sent when the dataChannel connection status is modified * **Event Data** * - **status**: The dataChannel connection status */ ON_STATUS_CHANGED = "ON_STATUS_CHANGED", /** * @eventProperty * This `RBEvent` is sent when a message is received in a dataChannel * **Event Data** * - **message**: The message (any) */ ON_MESSAGE_RECEIVED = "ON_MESSAGE_RECEIVED", /** * @eventProperty * This `RBEvent` is sent a new subscribtion is added to a bubble dataChannel * **Event Data** * - **user**: The added user subscribtion */ ON_SUBSCRIPTION_ADDED = "ON_SUBSCRIPTION_ADDED", /** * @eventProperty * This `RBEvent` is sent a subscribtion is removed from a bubble dataChannel * **Event Data** * - **user**: The removed user subscribtion */ ON_SUBSCRIPTION_REMOVED = "ON_SUBSCRIPTION_REMOVED" } export interface IDataChannelEvents { /** * This event is sent when the data channel connection status is modified */ ON_STATUS_CHANGED: DataChannelStatus; /** * This event is sent when a message is received in a data channel */ ON_MESSAGE_RECEIVED: { message: unknown; }; /** * This event is sent when a subscription is added to a bubble data channel */ ON_SUBSCRIPTION_ADDED: User; /** * This even is sent when a subscription is removed from a bubble data channel */ ON_SUBSCRIPTION_REMOVED: User; } export type DataChannelID = Branded; export interface DataChannel extends EventableService { /** * DataChannel identifier * @readonly */ id: DataChannelID; /** * DataChannel description string * @readonly */ description?: string; /** * DataChannel publisher * @readonly */ publisher?: Contact; /** * DataChannel bubble * @readonly */ bubble?: Bubble; /** * DataChannel status * @readonly */ status?: DataChannelStatus; /** * Leave a dataChannel */ leave(): Promise; /** * Accept a dataChannel */ accept(): Promise; /** * Refuse a dataChannel */ refuse(): Promise; /** * Delete a dataChannel */ delete(): Promise; /** * Send data on connected dataChannel * @param data - the data to send */ sendMessage(data: any): void; /** * Send file on connected dataChannel * @param file - the file to send * @internal */ sendFile(file: File): void; /** * Subscribe to updates on the current dataChannel (all events are of RBEvent type); * @param handler - The call-back function that will be subscribed to the RxJS subject * @param filterEvent - a list of event names that the user wants to receive when subscribing (used a filter) */ subscribe(handler: (event: RBEvent) => any, filterEvent?: string | string[]): Subscription; } /** * @internal */ export declare class DataChannel_RB implements DataChannel { id: DataChannelID; name?: string; description?: string; ressourceId?: string; type?: 'p2p' | 'janus'; bubble?: Bubble; publisher?: Contact; publisherFullJid?: string; sessionId?: string; session?: JingleSession; affiliation?: string; rtcDataChannel: RTCDataChannel; _status: DataChannelStatus; readonly _statusSubject: Subject; private chunkLength; private readonly rxSubject; private readonly dataChannelService; static create(): DataChannel_RB; private constructor(); get status(): DataChannelStatus; set status(status: DataChannelStatus); events(...eventNames: EventNames[]): import("rxjs").Observable>>; subscribe(handler: (event: RBEvent) => any, eventNames?: string | string[]): Subscription; sendEvent(eventName: EventName, data: IDataChannelEvents[EventName]): void; leave(): Promise; accept(): Promise; refuse(): Promise; delete(): Promise; sendMessage(data: any): void; sendFile(file: File): Promise; private onReadAsDataURL; toJSON(): any; } //# sourceMappingURL=dataChannel.model.d.ts.map