aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/rtcpeerconnection/onicecandidate
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/rtcpeerconnection/onicecandidate
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/rtcpeerconnection/onicecandidate')
-rw-r--r--files/zh-cn/web/api/rtcpeerconnection/onicecandidate/index.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/rtcpeerconnection/onicecandidate/index.html b/files/zh-cn/web/api/rtcpeerconnection/onicecandidate/index.html
new file mode 100644
index 0000000000..6389f53f6a
--- /dev/null
+++ b/files/zh-cn/web/api/rtcpeerconnection/onicecandidate/index.html
@@ -0,0 +1,65 @@
+---
+title: RTCPeerConnection.onicecandidate
+slug: Web/API/RTCPeerConnection/onicecandidate
+translation_of: Web/API/RTCPeerConnection/onicecandidate
+---
+<p>{{APIRef("WebRTC")}}</p>
+
+<p><span class="seoSummary"> <code>RTCPeerConnection</code> 的属性 <strong>{{domxref("RTCPeerConnection.onicecandidate", "onicecandidate")}}</strong> (是一个事件触发器 {{domxref("EventHandler")}}) 能够让函数在事件{{event("icecandidate")}}发生在实例  {{domxref("RTCPeerConnection")}} 上时被调用。 <strong>只要本地代理{{Glossary("ICE")}} 需要通过信令服务器传递信息给其他对等端时就会触发</strong>。</span> 这让本地代理与其他对等体相协商而浏览器本身在使用时无需知道任何详细的有关信令技术的细节,只需要简单地应用这种方法就可使用您选择的任何消息传递技术将ICE候选发送到远程对等方。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox"><em>rtcPeerConnection</em>.onicecandidate = <em>eventHandler</em>;
+</pre>
+
+<h3 id="Value">Value</h3>
+
+<p><font><font>这应该设置为您提供的函数,该函数接受</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceEvent" title="RTCPeerConnectionIceEvent接口表示与具有目标的ICE候选相关的事件,通常是RTCPeerConnection。"><code>RTCPeerConnectionIceEvent</code></a><font><font>表示</font></font><code><a href="https://developer.mozilla.org/en-US/docs/Web/Events/icecandidate" title="/en-US/docs/Web/Events/icecandidate">icecandidate</a></code><font><font>事件</font><font>的</font><font>对象</font><font>作为输入</font><font>。</font><font>该功能应该</font><font>通过信令服务器</font><font>将可以在事件</font><font>属性中</font><font>找到</font><font>其</font></font><a href="https://developer.mozilla.org/en-US/docs/Glossary/SDP" title="SDP:SDP(会话描述协议)是描述对等连接的标准。 SDP包含音频和视频的编解码器,源地址和定时信息。"><font><font>SDP</font></font></a><font><font>的ICE候选者传递</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnectionIceEvent/candidate" title="RTCPeerConnectionIceEvent接口的只读候选属性返回与事件关联的RTCIceCandidate。"><code>candidate</code></a><font><font>给远程对等体。</font></font></p>
+
+<p><font><font>如果事件的</font></font><code>candidate</code><font><font>属性是</font></font><code>null</code><font><font>,ICE收集已经完成。</font><font>不应将此消息发送到远程对等方。</font><font>发生这种情况时,连接</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/iceGatheringState" title="只读属性RTCPeerConnection.iceGatheringState返回一个类型为RTCIceGatheringState的枚举,用于描述连接的ICE收集状态。 这使您可以检测,例如,ICE候选人的集合何时完成。"><code>iceGatheringState</code></a><font><font>也已更改为</font></font><code>complete</code><font><font>。</font><font>你不需要明确地注意这一点; </font><font>相反,如果你需要感知信令的结束,你应该注意一个</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event" title="当ICE候选者收集过程的状态发生变化时,icegatheringstatechange事件将被发送到RTCPeerConnection上的onicegatheringstatechange事件处理程序。"><code>icegatheringstatechange</code></a><font><font>事件,表明ICE协商已经转变为</font></font><code>complete</code><font><font>状态。</font></font></p>
+
+<h2 id="Example">Example</h2>
+
+<p><font><font>下面的示例基于文章</font></font><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling"><font><font>信令和视频调用中</font></font></a><font><font>的代码,</font><font>为</font></font><code><a href="https://developer.mozilla.org/en-US/docs/Web/Events/icecandidate" title="/en-US/docs/Web/Events/icecandidate">icecandidate</a></code><font><font>事件</font><font>设置处理程序,</font><font>以便将候选项发送到远程对等方。</font></font></p>
+
+<pre class="brush: js">pc.onicecandidate = function(event) {
+ if (event.candidate) {
+ // Send the candidate to the remote peer
+ } else {
+ // All ICE candidates have been sent
+ }
+}</pre>
+
+<p><font><font>请注意,当检测到协议结束时</font></font>{{domxref("RTCPeerConnectionIceEvent.candidate", "candidate")}} 属性为 <code>null</code>.</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="https://w3c.github.io/webrtc-pc/#widl-RTCPeerConnection-onicecandidate" hreflang="en" lang="en" rel="noopener"><font><font>WebRTC 1.0:浏览器之间的实时通信</font></font><br>
+ <small lang="en-US"><font><font>该规范中“RTCPeerConnection.onicecandidate”的定义。</font></font></small></a></td>
+ <td>{{ Spec2('WebRTC 1.0') }}</td>
+ <td>Initial specification.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性"><font><font>浏览器兼容性</font></font></h2>
+
+
+
+<p>{{Compat("api.RTCPeerConnection.onicecandidate")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>The {{event("icecandidate")}} event and its type, {{domxref("RTCPeerConnectionIceEvent")}}.</li>
+</ul>