import { Peer } from './peer'; import { StreamCollection } from './internal/stream_collection'; import { ChannelCollection } from './internal/channel_collection'; import { SignalingPeer, StreamTransceiverFactoryArray, StreamInitData, StreamTransceiverFactory } from './types'; import { PeerConnection, PeerConnectionFingerprints } from './peer_connection'; import { LocalPeer } from './local_peer'; import { Stream } from './stream'; import { DataChannel } from './data_channel'; /** * @module rtc */ /** * Represents a remote user of the room * @class rtc.RemotePeer * @extends rtc.Peer * * @constructor * @param {rtc.PeerConnection} peer_connection The underlying peer connection * @param {rtc.SignalingPeer} signaling The signaling connection to the peer * @param {rtc.LocalPeer} local The local peer * @param {Object} options The options object as passed to `Room` */ export declare class RemotePeer extends Peer { peer_connection: PeerConnection; signaling: S; local: LocalPeer; options: Record; private_streams: Record; private_channels: Record; stream_collection: StreamCollection; streams: Record>; channel_collection: ChannelCollection; channels: Record>; channels_desc: Record; connect_p?: Promise; /** * Message received from peer through signaling * @event message * @param data The payload of the message */ /** * The remote peer left or signaling closed * @event left */ /** * A new stream is available from the peer * @event stream_added * @param {String} name Name of the stream * @param {Promise -> rtc.Stream} stream Promise of the stream */ /** * A new data channel is available from the peer * @event data_channel_added * @param {String} name Name of the channel * @param {Promise -> rtc.DataChannel} channel Promise of the channel */ /** * The connection to the peer supplied by the signaling implementation * @property signaling * @type rtc.signaling.SignalingPeer */ constructor(peer_connection: PeerConnection, signaling: S, local: LocalPeer, options: Record); negotiate(): void; status(key: string): any; /** * Send a message to the peer through signaling * @method message * @param data The payload * @return {Promise} Promise which is resolved when the data was sent */ message(data: any): Promise; /** * Connect to the remote peer to exchange streams and create data channels * @method connect * @return {Promise} Promise which will resolved when the connection is established */ connect(): Promise; private applyStreams; /** * Closes the connection to the peer * @method close */ close(): void; /** * Get a stream from the peer. Has to be sent by the remote peer to succeed. * @method stream * @param {String} [name='stream'] Name of the stream * @return {Promise -> rtc.Stream} Promise of the stream */ stream(name?: string): Promise; /** * Add local stream to be sent to this remote peer * * If you use this method you have to set `auto_connect` to `false` in the options object and call `connect()` manually on all remote peers. * * @method addStream * @param {String} [name='stream'] Name of the stream * @param {Promise -> rtc.Stream | rtc.Stream | Object} stream The stream, a promise to the stream or the configuration to create a stream with `rtc.Stream.createStream()` * @return {Promise -> rtc.Stream} Promise of the stream which was added */ addStream(obj: Stream | Promise | MediaStreamConstraints, transceivers?: StreamTransceiverFactory | StreamTransceiverFactoryArray): Promise; addStream(name: string, obj: Stream | Promise | MediaStreamConstraints, transceivers?: StreamTransceiverFactory | StreamTransceiverFactoryArray): Promise; removeStream(name?: string): void; /** * Get a data channel to the remote peer. Has to be added by local and remote side to succeed. * @method channel * @param {String} [name='data'] Name of the data channel * @return {Promise -> rtc.DataChannel} Promise of the data channel */ channel(name?: string): Promise; /** * Add data channel which will be negotiated with this remote peer * * If you use this method you have to set `auto_connect` to `false` in the options object and call `connect()` manually on all remote peers. * * @method addDataChannel * @param {String} [name='data'] Name of the data channel * @param {Object} [desc={ordered: true}] Options passed to `RTCDataChannel.createDataChannel()` */ addDataChannel(desc?: RTCDataChannelInit): Promise; addDataChannel(name: string, desc?: RTCDataChannelInit): Promise; /** * Checks whether the peer is the local peer. Returns always `false` on this * class. * @method currentFingerprints * @return {Object} Returns fingerprint used in underlying peer connection */ currentFingerprints(): PeerConnectionFingerprints; /** * Checks whether the peer is the local peer. Returns always `false` on this * class. * @method isLocal * @return {Boolean} Returns `false` */ isLocal(): boolean; }