API Docs for:
Show:

rtc.RemotePeer Class

Extends rtc.Peer
Module: rtc

Represents a remote user of the room

Constructor

rtc.RemotePeer

(
  • peer_connection
  • signaling
  • local
  • options
)

Parameters:

  • peer_connection rtc.PeerConnection

    The underlying peer connection

  • signaling rtc.SignalingPeer

    The signaling connection to the peer

  • local rtc.LocalPeer

    The local peer

  • options Object

    The options object as passed to Room

Methods

addDataChannel

(
  • [name='data']
  • [desc={ordered: true}]
)

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.

Parameters:

  • [name='data'] String optional

    Name of the data channel

  • [desc={ordered: true}] Object optional

    Options passed to RTCDataChannel.createDataChannel()

addStream

(
  • [name='stream']
  • stream
)
Promise -> rtc.Stream

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.

Parameters:

  • [name='stream'] String optional

    Name of the stream

  • stream Promise -> rtc.Stream | rtc.Stream | Object

    The stream, a promise to the stream or the configuration to create a stream with rtc.Stream.createStream()

Returns:

Promise -> rtc.Stream:

Promise of the stream which was added

channel

(
  • [name='data']
)
Promise -> rtc.DataChannel

Get a data channel to the remote peer. Has to be added by local and remote side to succeed.

Parameters:

  • [name='data'] String optional

    Name of the data channel

Returns:

Promise -> rtc.DataChannel:

Promise of the data channel

close

()

Closes the connection to the peer

connect

() Promise

Connect to the remote peer to exchange streams and create data channels

Returns:

Promise:

Promise which will resolved when the connection is established

isLocal

() Boolean

Checks whether the peer is the local peer. Returns always false on this class.

Returns:

Boolean:

Returns false

message

(
  • data
)
Promise

Send a message to the peer through signaling

Parameters:

  • data Object

    The payload

Returns:

Promise:

Promise which is resolved when the data was sent

status

(
  • key
)

Inherited from rtc.Peer: src/peer.coffee:23

Get a value of the status object

Parameters:

  • key String

    The key

Returns:

The value

stream

(
  • [name='stream']
)
Promise -> rtc.Stream

Get a stream from the peer. Has to be sent by the remote peer to succeed.

Parameters:

  • [name='stream'] String optional

    Name of the stream

Returns:

Promise -> rtc.Stream:

Promise of the stream

Properties

signaling

rtc.signaling.SignalingPeer

The connection to the peer supplied by the signaling implementation

Events

data_channel_added

(
  • name
  • channel
)

A new data channel is available from the peer

Parameters:

  • name String

    Name of the channel

  • channel Promise -> rtc.DataChannel

    Promise of the channel

left

()

The remote peer left or signaling closed

message

(
  • data
)

Message received from peer through signaling

Parameters:

  • data Object

    The payload of the message

status_changed

(
  • status
)

Inherited from rtc.Peer: src/peer.coffee:12

The status of the peer has changed

Parameters:

  • status Object

    The new status object

stream_added

(
  • name
  • stream
)

A new stream is available from the peer

Parameters:

  • name String

    Name of the stream

  • stream Promise -> rtc.Stream

    Promise of the stream