我正在尝试与两个对等方建立p2p音频/视频连接。以下:Getting started with WebRTC。
在两台PC之间的LAN环境中我的家中工作正常,但在运行时会抛出错误信息 在我公司的局域网环境中,有一部分是javascript
function processSignalingMessage(message) {
var msg = JSON.parse(message);
if (msg.type === 'offer') {
// Callee creates PeerConnection
if (!initiator && !started)
maybeStart();
// We only know JSEP version after createPeerConnection().
if (isRTCPeerConnection)
pc.setRemoteDescription(new RTCSessionDescription(msg));
else
pc.setRemoteDescription(pc.SDP_OFFER,
new SessionDescription(msg.sdp));
doAnswer();
} else if (msg.type === 'answer' && started) {
pc.setRemoteDescription(new RTCSessionDescription(msg));
} else if (msg.type === 'candidate' && started) {
var candidate = new RTCIceCandidate({
sdpMLineIndex : msg.label,
candidate : msg.candidate
});
pc.addIceCandidate(candidate);
} else if (msg.type === 'bye' && started) {
onRemoteHangup();
}
}
当第一个用户收到消息"键入":"候选人",出错
和控制台日志的一部分:
答案 0 :(得分:0)
我认为您可以使用msg.candidate
创建ICE候选消息var candidate = new RTCIceCandidate(msg.candidate);
并将其传递到addIceCandidate
函数