blob: ce202a7d8f0972f6fff03adb929a50021972738d (
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
103
104
105
106
107
108
109
110
|
---
title: RTCPeerConnection.iceConnectionState
slug: Web/API/RTCPeerConnection/iceConnectionState
translation_of: Web/API/RTCPeerConnection/iceConnectionState
---
<p>{{APIRef("WebRTC")}}{{SeeCompatTable}}</p>
<p><code><strong>RTCPeerConnection.iceConnectionState</strong></code> 是一个只读属性,用于描述连接的ICE连接状态,返回值为枚举类型。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"> var state = <em>peerConnection</em>.iceConnectionState;</pre>
<h3 id="返回值">返回值</h3>
<p><code>RTCIceConnectionState的返回值为下面列举中的一种</code>:</p>
<ul>
<li><code>"new"</code>: ICE 代理正在搜集地址或者等待远程候选可用。</li>
<li><code>"checking"</code>: ICE 代理已收到至少一个远程候选,并进行校验,无论此时是否有可用连接。同时可能在继续收集候选。</li>
<li><code>"connected"</code>: ICE代理至少对每个候选发现了一个可用的连接,此时仍然会继续测试远程候选以便发现更优的连接。同时可能在继续收集候选。</li>
<li><code>"completed"</code>: ICE代理已经发现了可用的连接,不再测试远程候选。</li>
<li><code>"failed"</code>: ICE候选测试了所有远程候选没有发现匹配的候选。也可能有些候选中发现了一些可用连接。</li>
<li><code>"disconnected"</code>: 测试不再活跃,这可能是一个暂时的状态,可以自我恢复。</li>
<li><code>"closed"</code>: ICE代理关闭,不再应答任何请求。</li>
</ul>
<h2 id="例子">例子</h2>
<pre>var pc = new RTCPeerConnection();
var state = pc.iceConnectionState;</pre>
<h2 id="Specifications" name="Specifications">规范</h2>
<table class="standard-table" style="height: 49px; width: 1000px;">
<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-iceConnectionState', 'RTCPeerConnection.iceConnectionState') }}</td>
<td>{{ Spec2('WebRTC 1.0') }}</td>
<td>Initial specification.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容">浏览器兼容</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatVersionUnknown() }} [1]</td>
<td>{{ CompatVersionUnknown }} [1]</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatNo() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<p>[1] Though this property is not prefixed, the interface it belongs to is.</p>
<h2 id="参考文档">参考文档</h2>
<ul>
<li><a href="/en-US/docs/Web/Guide/API/WebRTC">WebRTC</a></li>
</ul>
|