W
W
websiller2018-07-18 08:07:27
WebRTC
websiller, 2018-07-18 08:07:27

When is the RTCPeerConnection.onicecandidate event fired?

When does the RTCPeerConnection.onicecandidate event occur? In those examples that I found, there is always a check:

yourConnection.onicecandidate = function (event) {
    if (event.candidate) {
      send({
        type: "candidate",
        candidate: event.candidate
      });
    }
  };

What is the if (event.candidate) check for here? Indeed, in theory, onicecandidate should be called when a candidate is generated, why then check whether it exists or not every time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MrNerub, 2019-02-15
@MrNerub

The point is that when it gets all the candidates, the last one will come with null value. It makes no sense to pass empty data to another user, so a condition is set.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question