Struct WebRTCPeerConnection

Interface to a WebRTC peer connection.

struct WebRTCPeerConnection ;

A WebRTC connection between the local computer and a remote peer. Provides an interface to connect, maintain and monitor the connection. Setting up a WebRTC connection between two peers from now on) may not seem a trivial task, but it can be broken down into 3 main steps: - The peer that wants to initiate the connection (A from now on) creates an offer and send it to the other peer (B from now on). - B receives the offer, generate and answer, and sends it to A). - A and B then generates and exchange ICE candidates with each other. After these steps, the connection should become connected. Keep on reading or look into the tutorial for more information.

Methods

NameDescription
addIceCandidate Add an ice candidate generated by a remote peer (and received over the signaling server). See iceCandidateCreated.
close Close the peer connection and all data channels associated with it. Note, you cannot reuse this object for a new connection unless you call initialize.
createDataChannel Returns a new WebRTCDataChannel (or null on failure) with given label and optionally configured via the options dictionary. This method can only be called when the connection is in state constant STATE_NEW. There are two ways to create a working data channel: either call createDataChannel on only one of the peer and listen to dataChannelReceived on the other, or call createDataChannel on both peers, with the same values, and the negotiated option set to true. Valid options are:
createOffer Creates a new SDP offer to start a WebRTC connection with a remote peer. At least one WebRTCDataChannel must have been created before calling this method. If this functions returns constant OK, sessionDescriptionCreated will be called when the session is ready to be sent.
getConnectionState Returns the connection state. See connectionstate.
initialize Re-initialize this peer connection, closing any previously active connection, and going back to state constant STATE_NEW. A dictionary of options can be passed to configure the peer connection. Valid options are:
poll Call this method frequently (e.g. in Node.process or Node.physicsProcess) to properly receive signals.
setLocalDescription Sets the SDP description of the local peer. This should be called in response to sessionDescriptionCreated. If type is answer the peer will start emitting iceCandidateCreated.
setRemoteDescription Sets the SDP description of the remote peer. This should be called with the values generated by a remote peer and received over the signaling server. If type is offer the peer will emit sessionDescriptionCreated with the appropriate answer. If type is answer the peer will start emitting iceCandidateCreated.

Enums

NameDescription
ConnectionState
Constants