【发布时间】:2019-09-13 21:01:10
【问题描述】:
我已经能够使用 webrtc 连接对等设备。我心中的问题是 RTCPeerConnection()- 在这里我们传递了 stun/turn url。但是当什么都没有通过时它也可以工作!
我想知道它是否在内部使用 google stun 服务器,如果是,为什么在他们的任何文档中都没有提到它。
peerConnection = new RTCPeerConnection();
peerConnection.setRemoteDescription(description)
.then(() => peerConnection.createAnswer())
.then(sdp => peerConnection.setLocalDescription(sdp))
.then(function () {
socket.emit('answer', id, peerConnection.localDescription);
});
peerConnection.ontrack = function(event) {
video.srcObject = event.streams[0];
};
peerConnection.onicecandidate = function(event) {
if (event.candidate) {
socket.emit('candidate', id, event.candidate);
}
【问题讨论】:
-
本地网络中没有 STUN 服务器的情况下将建立连接。
-
请为答案投票,否则其他用户不会认为是正确答案。永远记住首先投票,然后勾选作为未来问题的正确答案。欢迎来到stackover流程:)
标签: webrtc peer simplewebrtc