【发布时间】:2015-04-15 06:46:11
【问题描述】:
我想将流数据(ArrayBuffer 的序列)从 Chrome 扩展程序发送到 Chrome 应用程序,因为 Chrome message API(包括 chrome.runtime.sendMessage、postMessage...)不支持 ArrayBuffer 和JS数组性能不好,我只好尝试其他方法。最终,我发现 WebRTC over RTCDataChannel 对我来说可能是一个很好的解决方案。
我已成功通过RTCDataChannel 发送字符串,但是当我尝试发送ArrayBuffer 时,我得到了:
code: 19
message: "Failed to execute 'send' on 'RTCDataChannel': Could not send data"
name: "NetworkError"
这似乎不是bandwidths limits 问题,因为即使我发送了一个字节的数据,它也失败了。这是我的代码:
pc = new RTCPeerConnection(configuration, { optional: [ { RtpDataChannels: true } ]});
//...
var dataChannel = m.pc.createDataChannel("mydata", {reliable: true});
//...
var ab = new ArrayBuffer(8);
dataChannel.send(ab);
在 OSX 10.10.1、Chrome M40 (Stnble)、M42(Canary) 上测试;在 Chromebook M40 上。
我已经为 WebRTC here 提交了一个错误。
【问题讨论】:
-
曾经在这个问题上取得任何进展吗?我现在在一条类似的船上。通过传输数据。在 Chrome 中使用字符串的 WebRTC 非常慢。
-
@NickJennings 得到了解决方案,请参阅我的答案。
标签: google-chrome google-chrome-extension webrtc google-chrome-app rtcdatachannel