rtcPeerConnection.onicecandidate = (event) => {
if (event.candidate !== null) {
sendCandidateToRemotePeer(event.candidate);
} else {
/* there are no more candidates coming during this negotiation */
}
};RTCPeerConnection: icecandidate event / notebook
RTCPeerConnection: icecandidate event
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
pc.addEventListener("icegatheringstatechange", (ev) => {
switch (pc.iceGatheringState) {
case "new":
/* gathering is either just starting or has been reset */
break;
case "gathering":
/* gathering has begun or is ongoing */
break;
case "complete":
/* gathering has ended */
break;
}
});pc.addEventListener("icecandidate", (ev) => {
if (ev.candidate !== null) {
sendMessage({
type: "new-ice-candidate",
candidate: ev.candidate,
});
}
});pc.onicecandidate = (ev) => {
if (ev.candidate !== null) {
sendMessage({
type: "new-ice-candidate",
candidate: ev.candidate,
});
}
};