rtc.PeerConnection Class
Wrapper around native RTCPeerConnection
Provides events for new streams and data channels. Signaling information has to be forwarded from events emitted by this object to the remote PeerConnection.
Constructor
rtc.PeerConnection
-
offering
-
options
Parameters:
-
offering
BooleanTrue if the local peer should initiate the connection
-
options
ObjectOptions object passed on from
Room
Item Index
Methods
Methods
_connectError
-
err
Mark connection attempt as failed
Parameters:
-
err
ErrorError causing connection to fail
_oaOptions
()
Object
private
Returns the options for the offer/answer
Returns:
_offer
()
private
Create offer, set it on local description and emit it
_offer
()
private
Create answer, set it on local description and emit it
_processLocalSdp
-
sdp
Set local description and emit it
Parameters:
-
sdp
ObjectThe local SDP
Returns:
Promise which will be resolved once the local description was set successfully
_setRemoteDescription
-
sdp
Set the remote description
Parameters:
-
sdp
ObjectThe remote SDP
Returns:
Promise which will be resolved once the remote description was set successfully
addDataChannel
-
name
-
desc
Add DataChannel. Will only actually do something if offering
is true
.
Parameters:
-
name
StringName of the data channel
-
desc
ObjectOptions passed to
RTCPeerConnection.createDataChannel()
addIceCandidate
-
desc
Add a remote ICE candidate
Parameters:
-
desc
ObjectThe candidate
close
()
Close the connection to the remote peer
connect
()
Promise
Establish connection with remote peer. Connection will be established once both peers have called this functio
Returns:
Promise which will be resolved once the connection is established
signaling
-
data
Add new signaling information received from remote peer
Parameters:
-
data
ObjectThe signaling information
Events
closed
()
The PeerConnection was closed
data_channel_ready
-
channel
New DataChannel to the remote peer is ready to be used
Parameters:
-
channel
rtc.DataChannelThe data channel
ice_candiate
-
candidate
New local ICE candidate which should be signaled to remote peer
Parameters:
-
candidate
ObjectThe ice candidate
signaling
-
obj
New offer or answer which should be signaled to the remote peer
Parameters:
-
obj
ObjectThe signaling message
stream_added
-
stream
New remote stream was added to the PeerConnection
Parameters:
-
stream
rtc.StreamThe stream