When an ICE negotiation session runs out of candidates to propose for a given RTCIceTransport, it has completed gathering for a generation of candidates. That this has occurred is indicated by an icecandidate event whose candidate string is empty ( "" ).
**> ** > You should deliver this to the remote peer just like any standard candidate, as described under Sharing a new candidate above. This ensures that the remote peer is given the end-of-candidates notification as well.
However, the snippet introduced in the same article does not handle the empty string candidate.
You’re right! This is contradictory (or seems to be). The reason is simple: an icecandidate event with an empty candidate.candidate string says “the other peer’s client says it’s done sending stuff, but the remote user agent hasn’t yet”. This message should be forwarded to the other peer as normal, so that the other peer knows that things are winding down.
The nullcandidate reference is really mostly there for backward compatibility, but means that not only is the current gathering group finished, but all gathering is finished.
Generally speaking, you should do nothing in your handler for the icecandidate event other than transmit the messages to the remote peer. Thus, this is all you need:
This message should be forwarded to the other peer as normal, so that the other peer knows that things are winding down.
You are saying about the empty (“”) candidate. However, in onicecandidate handler, it does not send this empty candidate (the if condition is evaluated to false)