我在完成优惠和回答后添加了IceCandidate,但它仍然会调用错误:' RTCPeerConnection':无法添加icecandidate。这是我的代码的一部分:
else if (data.user_type == 'signaling') {
if (!rtcPeerConn)
startSignaling();
var message = JSON.parse(data.user_data);
if (message.sdp) {
rtcPeerConn.setRemoteDescription(new RTCSessionDescription(message.sdp),
function () { // if we received an offer, we need to answer
if (rtcPeerConn.remoteDescription.type == 'offer' && myUserType=="doctor") {
rtcPeerConn.createAnswer(sendLocalDesc, logError);
}
}, logError);
} else {
rtcPeerConn.addIceCandidate(new RTCIceCandidate(message.candidate));
}
}