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:
-
offeringBooleanTrue if the local peer should initiate the connection
-
optionsObjectOptions object passed on from
Room
Item Index
Methods
Methods
_connectError
-
err
Mark connection attempt as failed
Parameters:
-
errErrorError 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:
-
sdpObjectThe local SDP
Returns:
Promise which will be resolved once the local description was set successfully
_setRemoteDescription
-
sdp
Set the remote description
Parameters:
-
sdpObjectThe 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:
-
nameStringName of the data channel
-
descObjectOptions passed to
RTCPeerConnection.createDataChannel()
addIceCandidate
-
desc
Add a remote ICE candidate
Parameters:
-
descObjectThe 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:
-
dataObjectThe signaling information
Events
closed
()
The PeerConnection was closed
data_channel_ready
-
channel
New DataChannel to the remote peer is ready to be used
Parameters:
-
channelrtc.DataChannelThe data channel
ice_candiate
-
candidate
New local ICE candidate which should be signaled to remote peer
Parameters:
-
candidateObjectThe ice candidate
signaling
-
obj
New offer or answer which should be signaled to the remote peer
Parameters:
-
objObjectThe signaling message
stream_added
-
stream
New remote stream was added to the PeerConnection
Parameters:
-
streamrtc.StreamThe stream
