addIceCandidate method

JSPromise<JSAny?> addIceCandidate([
  1. RTCIceCandidateInit candidate,
  2. VoidFunction successCallback,
  3. RTCPeerConnectionErrorCallback failureCallback
])

The addIceCandidate() method of the RTCPeerConnection interface adds a new remote candidate to the connection's remote description, which describes the state of the remote end of the connection.

When a website or app using RTCPeerConnection receives a new ICE candidate from the remote peer over its signaling channel, it delivers the newly-received candidate to the browser's agent by calling RTCPeerConnection.addIceCandidate(). This adds this new remote candidate to the RTCPeerConnection's remote description, which describes the state of the remote end of the connection.

If the candidate parameter is missing or a value of null is given when calling addIceCandidate(), the added ICE candidate is an "end-of-candidates" indicator. The same is the case if the value of the specified object's RTCIceCandidate.candidate is either missing or an empty string (""), it signals that all remote candidates have been delivered.

The end-of-candidates notification is transmitted to the remote peer using a candidate with an a-line value of end-of-candidates.

During negotiation, your app will likely receive many candidates which you'll deliver to the ICE agent in this way, allowing it to build up a list of potential connection methods. This is covered in more detail in the articles WebRTC connectivity and Signaling and video calling.

Implementation

external JSPromise<JSAny?> addIceCandidate([
  RTCIceCandidateInit candidate,
  VoidFunction successCallback,
  RTCPeerConnectionErrorCallback failureCallback,
]);