|
@@ -32,6 +32,11 @@ function DataConnection(peer, provider, options) {
|
|
|
// For storing large data.
|
|
|
this._chunkedData = {};
|
|
|
|
|
|
+ if (this.options._payload) {
|
|
|
+ this._peerBrowser = this.options._payload.browser;
|
|
|
+ this._peerSupports = this.options._payload.supports;
|
|
|
+ }
|
|
|
+
|
|
|
Negotiator.startConnection(
|
|
|
this,
|
|
|
this.options._payload || {
|
|
@@ -163,8 +168,10 @@ DataConnection.prototype.send = function(data, chunked) {
|
|
|
var utf8 = (this.serialization === 'binary-utf8');
|
|
|
var blob = util.pack(data, utf8);
|
|
|
|
|
|
- // For Chrome-Firefox interoperability, we need to make Firefox "chunking" the data it sends out. Future sophistication of this approach could make the decision on chunking dependent on the remote browser.
|
|
|
- if (/*util.browser !== 'Firefox' && */!chunked && blob.size > util.chunkedMTU) {
|
|
|
+ // For Chrome-Firefox interoperability, we need to make Firefox "chunk"
|
|
|
+ // the data it sends out.
|
|
|
+ var needsChunking = util.chunkedBrowsers.indexOf(this._peerBrowser) !== -1 || util.browser !== 'Firefox';
|
|
|
+ if (needsChunking && !chunked && blob.size > util.chunkedMTU) {
|
|
|
this._sendChunks(blob);
|
|
|
return;
|
|
|
}
|
|
@@ -174,7 +181,7 @@ DataConnection.prototype.send = function(data, chunked) {
|
|
|
util.blobToBinaryString(blob, function(str) {
|
|
|
self._bufferedSend(str);
|
|
|
});
|
|
|
- } else if (!util.supports.binaryBlob) {
|
|
|
+ } else if (!util.supports.binaryBlob || (this._peerSupports && !this._peerSupports.binaryBlob)) {
|
|
|
// We only do this if we really need to (e.g. blobs are not supported),
|
|
|
// because this conversion is costly.
|
|
|
util.blobToArrayBuffer(blob, function(ab) {
|
|
@@ -241,6 +248,9 @@ DataConnection.prototype.handleMessage = function(message) {
|
|
|
|
|
|
switch (message.type) {
|
|
|
case 'ANSWER':
|
|
|
+ this._peerBrowser = payload.browser;
|
|
|
+ this._peerSupports = payload.supports;
|
|
|
+
|
|
|
// Forward to negotiator
|
|
|
Negotiator.handleSDP(message.type, this, payload.sdp);
|
|
|
break;
|