首次尝试连接时,onicecandidate返回空候选者

时间:2020-06-08 09:39:27

标签: webrtc stun turn video-conferencing

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>

0 个答案:

没有答案