sam-vi / webrtc-icecontroller

RTCIceController interface extension to the WebRTC 1.0 Web API
https://sam-vi.github.io/webrtc-icecontroller/
Other
1 stars 0 forks source link

Avoiding ever sending STUN_BINDING requests #6

Closed shacharz closed 1 year ago

shacharz commented 1 year ago

Making sure the functionality is supported, If I read the spec correctly, this will be achieved like this, right?

const iceController = new RTCIceController();
iceController.onicepingproposed = (candidatePair)=>{
  return shouldTryToProbePair(candidatePair);
}
const PC = new RTCPeercConnection({iceController})
...
sam-vi commented 1 year ago

Correct, although Event.returnValue is deprecated so the appropriate way would be

const iceController = new RTCIceController();
iceController.addEventListener('icepingproposed', event => {
  if (!shouldTryToProbePair(event.candidatePair)) {
    event.preventDefault();
  }
});