From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../rtcpeerconnection/onicecandidate/index.html | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 files/zh-cn/web/api/rtcpeerconnection/onicecandidate/index.html (limited to 'files/zh-cn/web/api/rtcpeerconnection/onicecandidate') 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 +--- +

{{APIRef("WebRTC")}}

+ +

 RTCPeerConnection 的属性 {{domxref("RTCPeerConnection.onicecandidate", "onicecandidate")}} (是一个事件触发器 {{domxref("EventHandler")}}) 能够让函数在事件{{event("icecandidate")}}发生在实例  {{domxref("RTCPeerConnection")}} 上时被调用。 只要本地代理{{Glossary("ICE")}} 需要通过信令服务器传递信息给其他对等端时就会触发 这让本地代理与其他对等体相协商而浏览器本身在使用时无需知道任何详细的有关信令技术的细节,只需要简单地应用这种方法就可使用您选择的任何消息传递技术将ICE候选发送到远程对等方。

+ +

Syntax

+ +
rtcPeerConnection.onicecandidate = eventHandler;
+
+ +

Value

+ +

这应该设置为您提供的函数,该函数接受RTCPeerConnectionIceEvent表示icecandidate事件对象作为输入该功能应该通过信令服务器将可以在事件属性中找到SDP的ICE候选者传递candidate给远程对等体。

+ +

如果事件的candidate属性是null,ICE收集已经完成。不应将此消息发送到远程对等方。发生这种情况时,连接iceGatheringState也已更改为complete你不需要明确地注意这一点; 相反,如果你需要感知信令的结束,你应该注意一个icegatheringstatechange事件,表明ICE协商已经转变为complete状态。

+ +

Example

+ +

下面的示例基于文章信令和视频调用中的代码,icecandidate事件设置处理程序,以便将候选项发送到远程对等方。

+ +
pc.onicecandidate = function(event) {
+  if (event.candidate) {
+    // Send the candidate to the remote peer
+  } else {
+    // All ICE candidates have been sent
+  }
+}
+ +

请注意,当检测到协议结束时{{domxref("RTCPeerConnectionIceEvent.candidate", "candidate")}} 属性为 null.

+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
WebRTC 1.0:浏览器之间的实时通信
+ 该规范中“RTCPeerConnection.onicecandidate”的定义。
{{ Spec2('WebRTC 1.0') }}Initial specification.
+ +

浏览器兼容性

+ + + +

{{Compat("api.RTCPeerConnection.onicecandidate")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf