html - 如何检测断开的 RTCPeerConnection

标签 html webrtc

我正在 Chrome 浏览器中运行 WebRTC 演示,并且我已经可以设置视频 session 。 但是,如果其中一个对等点断开连接(例如刷新浏览器),我不知道如何在另一端检测到它(并且可能会发出“对等点断开连接”消息)

我注意到在对等点断开连接后,我收到了一些ice候选,但我找不到任何属性可以帮助我发现这实际上是一个断开连接的事件。

我用谷歌搜索发现this

This would be handled via the "disconnected" state for RTCIceConnectionState. It will trigger after some TBD (currently ~5s) delay of not receiving liveness checks or media from the remote side

但我在其他人的对等对象中找不到这种“断开连接”状态。

你能给我更多关于这个的提示吗?谢谢

最佳答案

您需要检查此只读属性:

peerconnection.iceConnectionState === 'disconnected'

引用文献:

关于html - 如何检测断开的 RTCPeerConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15466997/

相关文章:

c# - 在运行时在服务器端在 C# 中查找 div

javascript - 如何在 Linux 中使用 WebRTC 制作命令行应用程序?

javascript - JavaScript 中的 WebRTC

javascript - 如何根据上一个下拉列表中的选择创建新的下拉列表

html - Div 不按内容扩展

javascript - WebRTC:通知用户由于网络或 CPU 导致的质量问题

android - 如何在 android 上播放 webrtc.AudioTrack(无视频)

webrtc - 虚拟视频设备 - v4l2loopback - webRTC

html - 如何通过 iframe 操作文本?

html - Glyphicons 在 Firefox 中没有正确对齐