aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/rtcpeerconnection/cantrickleicecandidates/index.html
blob: c7742e042b0f51fb40446481965f21839c37ab75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: RTCPeerConnection.canTrickleIceCandidates
slug: Web/API/RTCPeerConnection/canTrickleIceCandidates
translation_of: Web/API/RTCPeerConnection/canTrickleIceCandidates
---
<div>{{APIRef("WebRTC")}}</div>

<div>只读的 <span class="seoSummary"><strong>{{domxref("RTCPeerConnection")}}</strong></span> 属性 <code>canTrickleIceCandidates</code> 返回一个{{jsxref("Boolean")}},它指示远程对等端是否可以接受 <a href="https://tools.ietf.org/html/draft-ietf-mmusic-trickle-ice-02">trickled ICE candidates</a><br>
<br>
<strong>ICE trickling</strong><span class="tlid-translation translation" lang="zh-CN"><span title="">是在初始发送或回应已经发送给其他设备之后继续发送候选的过程。</span><br>
<br>
<span title="">仅在调用{{domxref("RTCPeerConnection.setRemoteDescription()")}}之后才设置此属性。</span> <span title="">理想情况下,您的信令协议提供了一种检测滴流支持的方法,因此您无需依赖此属性。</span> <span title="">WebRTC浏览器将始终支持</span></span>trickle ICE<span class="tlid-translation translation" lang="zh-CN"><span title=""></span> <span title="">如果不支持滴流,或者您无法辨别,则可以检查此属性的伪值,然后等待{{domxref("RTCPeerConnection.iceGatheringState","iceGatheringState")}}的值更改</span><span title="">在创建和发送之前“完成”。</span></span></div>

<div><span class="tlid-translation translation" lang="zh-CN"><span title="">这样,发送信息包含所有候选。</span></span></div>



<h2 id="语法">语法</h2>

<pre class="syntaxbox"> var <em>canTrickle</em> = <em>RTCPeerConnection</em>.canTrickleIceCandidates;</pre>

<h3 id="值"></h3>

<p><span class="tlid-translation translation" lang="zh-CN"><span title="">{{jsxref("Boolean")}} 如果远程对等体可以接受滴入的</span></span>ICE candidate<span class="tlid-translation translation" lang="zh-CN"><span title="">,则为true;如果不能,则为false。</span> <span title="">如果尚未建立远程对等方,则此值为null。</span></span></p>

<div class="note">
<p><strong>Note:</strong> <span class="tlid-translation translation" lang="zh-CN"><span title="">一旦本地对等方调用{{domxref("RTCPeerConnection.setRemoteDescription()")}},就确定该属性的值;</span> <span title="">ICE代理使用所提供的描述来确定远程对等体是否支持滴入的</span></span>ICE candidates<span class="tlid-translation translation" lang="zh-CN"><span title=""></span></span></p>
</div>

<h2 id="用例">用例</h2>

<pre class="brush: js">var pc = new RTCPeerConnection();
// The following code might be used to handle an offer from a peer when
// it isn't known whether it supports trickle ICE.
pc.setRemoteDescription(remoteOffer)
  .then(_ =&gt; pc.createAnswer())
  .then(answer =&gt; pc.setLocalDescription(answer))
  .then(_ =&gt;
    if (pc.canTrickleIceCandidates) {
      return pc.localDescription;
    }
    return new Promise(r =&gt; {
      pc.addEventListener('icegatheringstatechange', e =&gt; {
        if (e.target.iceGatheringState === 'complete') {
          r(pc.localDescription);
        }
      });
    });
  })
  .then(answer =&gt; sendAnswerToPeer(answer)) // signaling message
  .catch(e =&gt; handleError(e));

pc.addEventListener('icecandidate', e =&gt; {
  if (pc.canTrickleIceCandidates) {
    sendCandidateToPeer(e.candidate); // signaling message
  }
});
</pre>

<table class="gt-baf-table">
 <tbody>
  <tr class="gt-baf-entry">
   <td>
    <h2 class="gt-baf-cell gt-baf-term-text-parent" id="规范"><span class="gt-baf-term-text"><span class="gt-baf-cell gt-baf-word-clickable">规范</span></span></h2>
   </td>
   <td>
    <div class="gt-baf-cell gt-baf-translations gt-baf-translations-mobile"></div>
   </td>
  </tr>
 </tbody>
</table>

<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>{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-canTrickleIceCandidates', 'RTCPeerConnection.canTrickleIceCandidates') }}</td>
   <td>{{ Spec2('WebRTC 1.0') }}</td>
   <td>Initial specification.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性"><span class="tlid-translation translation" lang="zh-CN"><span title="">浏览器兼容性</span></span></h2>



<p>{{Compat("api.RTCPeerConnection.canTrickleIceCandidates")}}</p>

<h2 id="相关阅读">相关阅读</h2>

<ul>
 <li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li>
 <li>{{domxref("RTCPeerConnection.addIceCandidate()")}}</li>
 <li><a href="/en-US/docs/Web/API/WebRTC_API/Session_lifetime">Lifetime of a WebRTC session</a></li>
</ul>