/// import { Signaling, SignalingPeer, Channel } from '../types'; import { EventEmitter } from 'events'; /** * @module rtc.signaling */ /** * Signaling peer for multi user chats. * * For a detailed description of the signaling protocol see `rtc.signaling.MucSignaling` * * @extends rtc.signaling.SignalingPeer * @class rtc.signaling.MucSignalingPeer * * @constructor * @param {rtc.signaling.Channel} channel The channel to the siganling server * @param {String} peer_id The id of the remote peer * @param {Object} status The status of the remote peer * @param {Boolean} first Whether the local peer was in the room before the remote peer */ export declare class MucSignalingPeer extends EventEmitter implements SignalingPeer { channel: Channel; id: string; status: Record; first: boolean; /** * The id of the remote peer * @property id * @type String */ constructor(channel: Channel, id: string, status: Record, first: boolean); send(event: string, data: any): Promise; } /** * Signaling for multi user chats * * The following messages are sent to the server: * * // join the room. has to be sent before any other message. * // response will be 'joined' on success * // other peers in the room will get 'peer_joined' * { * "type": "join", * "status": { .. status .. } * } * * // leave the room. server will close the connectino. * { * "type": "leave" * } * * // update status object * // other peers will get 'peer_status' * { * "type": "status", * "status": { .. status .. } * } * * // send message to a peer. will be received as 'from' * { * "type": "to", * "peer": "peer_id", * "event": "event_id", * "data": { .. custom data .. } * } * * The following messages are received form the server: * * // joined the room. is the response to 'join' * { * "type": "joined", * "id": "own_id", * "peers": { * "peer_id": { .. status .. } * } * } * * // another peer joined the room. * { * "type": "peer_joined", * "peer": "peer_id", * "status": { .. status .. } * } * * // anosther peer updated its status object using 'status' * { * "type": "peer_status", * "peer": "peer_id", * "status": { .. status .. } * } * * // another peer left the room * { * "type": "peer_left", * "peer": "peer_id" * } * * // message from another peer sent by 'to' * { * "type": "from", * "peer": "peer_id", * "event": "event_id", * "data": { .. custom data .. } * } * * The messages transmitted in the `to`/`from` messages are emitted as events in `MucSignalingPeer` * * @extends rtc.signaling.Signaling * @class rtc.signaling.MucSignaling * * @constructor * @param {rtc.signaling.Channel} channel The channel to the signaling server */ export declare class MucSignaling extends EventEmitter implements Signaling { channel: Channel; join_p: Promise; connect_p?: Promise; status: Record; id?: string; /** * The id of the local peer. Only available after joining. * @property id * @type String */ constructor(channel: Channel); connect(): Promise; setStatus(status: Record): Promise; close(): Promise; }