RTCPeerConnection.onicecandidate属性
2019獨角獸企業重金招聘Python工程師標準>>>
RTCPeerConnection.onicecandidate屬性是一個EventHandler,它指定在RTCPeerConnection實例上發生icecandidate事件時要調用的函數。當本地ICE代理需要通過信令服務器向另一個對等體發送消息時,就會發生這種情況。這允許ICE代理與遠程對等體進行協商,而瀏覽器本身不需要知道關于用于信令的技術的任何細節;只需執行此方法即可使用您選擇的任何消息傳遞技術將ICE候選者發送給遠程對等體。
語法 RTCPeerConnection.onicecandidate = eventHandler;這應該被設置為您提供的函數,該函數接受表示icecandidate事件的RTCPeerConnectionIceEvent對象作為輸入。該功能應該通過信令服務器將在事件候選屬性中可以找到其SDP的ICE候選者發送給遠程對等體。 如果事件的候選資源為空,ICE收集完成。Example
下面的示例是基于信號和視頻調用的代碼,為icecandidate事件設置一個處理程序,以將候選者發送到遠程對等體。 pc.onicecandidate = function(event) { ? if (event.candidate) { ?? ?// Send the candidate to the remote peer ? } else { ?? ?// All ICE candidates have been sent ? } }SpecificationsEDIT
| Specification | Status | Comment |
| WebRTC 1.0: Real-time Communication Between Browsers | Working Draft | Initial specification. |
Browser compatibilityEDIT
·???????? Desktop
?
·???????? Mobile
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
| Basic support | (Yes)?[1] | (Yes) | 18?(18) [2] | No?support | (Yes) | ? |
[1] Though this property is not prefixed, the interface it belongs to was until Chrome 56.
[2] Though this property is not prefixed, the?RTCPeerConnection?interface it's a member of was until Firefox 44.
?轉載于:https://my.oschina.net/u/3053883/blog/900063
總結
以上是生活随笔為你收集整理的RTCPeerConnection.onicecandidate属性的全部內容,希望文章能夠幫你解決所遇到的問題。