次要是对于RTCPeerConnection的状态
connectionState和iceConnectionState
这两个状态用于对应的
事件onconnectionstatechange和oniceconnectionstatechange。
mdn的文档看的头大
整顿如下
RTCPeerConnection.oniceconnectionstatechange
iceConnectionState
ICE代理的状态及其与ICE服务器(STUN、TURN)的连贯
"new": 建设ICE连贯
ICE 代理正在收集地址或者期待近程候选可用。
"checking": 收集候选
ICE 代理已收到至多一个近程候选,并进行校验,无论此时是否有可用连贯。同时可能在持续收集候选。
"connected": 匹配到可用候选
已为连贯的所有组件找到可用的本地和近程候选配对,并且已建设连贯。此时依然会持续测试近程候选以便发现更优的连贯。同时可能在持续收集候选。
"completed": 匹配实现,连贯建设
ICE代理曾经发现了可用的连贯,不再测试近程候选。
"failed":没有适合候选
ICE候选测试了所有近程候选没有发现匹配的候选。也可能有些候选中发现了一些可用连贯。
"disconnected":网络稳定或者串流断开
RTPeerConnection至多有一个组件连贯失败。这可能是一个临时的状态,能够自我复原。这句话好坑
"closed": 断开ICE
ICE代理敞开,不再应答任何申请。
RTCPeerConnection.onconnectionstatechange
connectionState
rtc ice所有传输组件(RTCIceTransport or RTCDtlsTransport(底层传输)类型)的聚合状态
new 新建连贯
至多有一个的ICE传输组件(RTICETransport或RTCDTLTransport对象)处于new状态,
并且全副都不是以下状态:checking、connecting、failed、disconnected,或者所有连贯都处于closed状态.
connecting 连贯中
一个或多个ICE传输组件目前正在建设连贯;
也就是说,iceConnectionState正在checking或connected,并不是closed状态
connected 已连贯
至多有一个ICE传输组件connected或completed状态
所有ICE连贯要么在应用中(connected或completed),要么closed;
disconnected 断开
至多一个ICE传输组件处于断开状态,
其余都不是failed、connecting或checking状态
failed 连贯失败
ICE传输组件处于failed状态.
closed 敞开
RTCPeerConnection敞开
iceConnectionState要留神,网络稳定的时候,disconnected,connected会屡次触发oniceconnectionstatechange事件
发表回复