我可以重复使用“报价"吗?在 WebRTC 中进行多重连接? [英] Can I re-use an "offer" in WebRTC for mulitple connections?
问题描述
我开始学习 WebRTC 并在这里使用复制/粘贴有一个工作原型:https://github.com/aerik/webrtc(原型旨在在两个浏览器窗口中运行,不像许多其他示例在一个窗口中同时运行)
I'm starting to learn WebRTC and have a working prototype using copy/paste here: https://github.com/aerik/webrtc (the prototype is meant to be run in two browser windows, unlike many other examples that run both sides in one window)
我了解 WebRTC 是点对点,并且我需要为每组对等点建立连接.但是,我开始考虑发信号(还没有代码),我想知道要约".在我的原型中,我看到多次单击创建报价"会产生相同的字符串.所以,如果有客户端 A,并连接到客户端 B 和 C,看起来我会向他们发送相同的报价".如果这是正确的,那么第一步就很容易发出信号 - 客户端 A 将始终具有相同的报价,而我只需要收集来自已连接对等方的响应.
I understand that WebRTC is peer-to-peer and a I need a connection for every set of peers. However, I'm starting to think about signalling (no code yet) and I'm wondering about the "offer". In my prototype I see that clicking "create offer" multiple times results in the same string. So, if have client A, and connect to client B and C, it looks like I will send the same "offer" to both of them. If that's correct, it makes the first step of signalling easy - client A will always have the same offer, and I just have to gather responses from connected peers.
这是正确的理解吗?
推荐答案
并非如此,对等连接将为不同的商品生成不同的原始值(SDP 中的 o=
).
It is not, a peer connection will generate different origin values for different offers (o=
in the SDP).
相同的对等连接提议将包含相同的
但不同的
.
Same peer connection offers will contain same <sess-id>
but different <sess-version>
.
不同的对等连接会产生不同的
Different peer connections will produce different <sess-id>
您可以在 Chrome 中使用以下代码段进行检查:
You can check it with the following snippet in Chrome:
var a = new webkitRTCPeerConnection({});
a.createOffer().then(offer => $('#11').text(offer.sdp));
a.createOffer().then(offer => $('#12').text(offer.sdp));
var b = new webkitRTCPeerConnection({});
b.createOffer().then(offer => $('#21').text(offer.sdp));
b.createOffer().then(offer => $('#22').text(offer.sdp));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
First PC, first offer: <span id="11"></span><br/>
First PC, second offer: <span id="12"></span><br/>
Second PC, first offer: <span id="21"></span><br/>
Second PC, second offer: <span id="22"></span><br/>
您可以在 https://datatracker 中找到有关 SDP 的更多信息.ietf.org/doc/html/rfc4566#page-11
这篇关于我可以重复使用“报价"吗?在 WebRTC 中进行多重连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!