peerconnection.onicecandidate = handleIceCandidate;
我有onicecandidate的处理程序
function handleIceCandidate(event) {
console.log('icecandidate event: ', event);
if (event.candidate) {
sendMessage({
type: 'candidate',
label: event.candidate.sdpMLineIndex,
id: event.candidate.sdpMid,
candidate: event.candidate.candidate
});
} else {
console.log('End of candidates.');
}
}
以上是添加冰候选者的处理函数。但是,在启动套接字服务器后第一次调用时,似乎 event.candidate = null ,但是当我刷新页面并重试时,它可以与 event.candidate 中的有效候选对象一起使用。 strong>