RTCIceTransport: gatheringstatechange event
Baseline2024Newly available
Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Agatheringstatechange
event is sent to anRTCIceTransport
when itsICE candidate gathering state changes.
The gathering state, whose actual status can be found in the transport object'sgatheringState
property, indicates whether or not the ICE agent has begun gathering candidates on this transport, and if so, if it has finished doing so.
This event is not cancelable and does not bubble.
Syntax
Use the event name in methods likeaddEventListener()
, or set an event handler property.
addEventListener("gatheringstatechange", (event) => { })ongatheringstatechange = (event) => { }
Event type
A genericEvent
.
Examples
This example creates a handler forgatheringstatechange
events on eachRTCRtpSender
associated with a givenRTCPeerConnection
. Here, theaddEventListener()
method is called to add a listener forgatheringstatechange
events:
pc.getSenders().forEach((sender) => { sender.transport.iceTransport.addEventListener( "gatheringstatechange", (ev) => { let transport = ev.target; if (transport.gatheringState === "complete") { /* this transport has finished gathering candidates, but others may still be working on it */ } }, false, );});
Likewise, you can use theongatheringstatechange
event handler property:
pc.getSenders().forEach((sender) => { sender.transport.iceTransport.ongatheringstatechange = (ev) => { let transport = ev.target; if (transport.gatheringState === "complete") { /* this transport has finished gathering candidates, but others may still be working on it */ } };});
Specifications
Specification |
---|
WebRTC: Real-Time Communication in Browsers # event-icetransport-gatheringstatechange |
WebRTC: Real-Time Communication in Browsers # dom-rtcicetransport-ongatheringstatechange |