--- title: RTCPeerConnection.canTrickleIceCandidates slug: Web/API/RTCPeerConnection/canTrickleIceCandidates translation_of: Web/API/RTCPeerConnection/canTrickleIceCandidates ---
canTrickleIceCandidates
返回一个{{jsxref("Boolean")}},它指示远程对等端是否可以接受 trickled ICE candidates 。var canTrickle = RTCPeerConnection.canTrickleIceCandidates;
{{jsxref("Boolean")}} 如果远程对等体可以接受滴入的ICE candidate,则为true;如果不能,则为false。 如果尚未建立远程对等方,则此值为null。
Note: 一旦本地对等方调用{{domxref("RTCPeerConnection.setRemoteDescription()")}},就确定该属性的值; ICE代理使用所提供的描述来确定远程对等体是否支持滴入的ICE candidates。
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(_ => pc.createAnswer()) .then(answer => pc.setLocalDescription(answer)) .then(_ => if (pc.canTrickleIceCandidates) { return pc.localDescription; } return new Promise(r => { pc.addEventListener('icegatheringstatechange', e => { if (e.target.iceGatheringState === 'complete') { r(pc.localDescription); } }); }); }) .then(answer => sendAnswerToPeer(answer)) // signaling message .catch(e => handleError(e)); pc.addEventListener('icecandidate', e => { if (pc.canTrickleIceCandidates) { sendCandidateToPeer(e.candidate); // signaling message } });
规范 |
Specification | Status | Comment |
---|---|---|
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-canTrickleIceCandidates', 'RTCPeerConnection.canTrickleIceCandidates') }} | {{ Spec2('WebRTC 1.0') }} | Initial specification. |
{{Compat("api.RTCPeerConnection.canTrickleIceCandidates")}}