【发布时间】:2019-10-04 00:20:52
【问题描述】:
我在 Chrome 中有一个有效的 WebRTC 连接。它使用 1 个数据通道作为聊天应用程序的一部分。
我还想支持 Firefox,因此我需要更改一些不支持的事件: 对于RTCPeerConnection 以及DataChannel。
对数据通道的更改按预期工作:
//chrome implenetation
dc.onopen = this.conncectionStats.bind(this);
dc.onmessage = onMessage;
// chrome and firefox
dc.addEventListener('open', (event) => {
this.conncectionStats.bind(this)
});
dc.addEventListener('message', (event) => {
onMessage(event)
});
但是,在更改 PeerConnection 时会出现问题:
// chrome implenetation
pc.onconnectionstatechange = this.onConnectionStateChange.bind(this);
// chrome and firefox
pc.addEventListener('onconnectionstatechange', (event) => {
console.log("onconnectionstatechange fired")
this.onConnectionStateChange.bind(this);
})
该事件从未发生。任何想法为什么会这样?
事件应该是correct,但另一方面,MDN Web Docs 上缺少文档。
【问题讨论】:
标签: javascript firefox events webrtc