Michelle Bu 12 жил өмнө
parent
commit
18bb810a08

+ 8 - 1
lib/connectionmanager.js

@@ -141,6 +141,9 @@ ConnectionManager.prototype._makeOffer = function() {
   var self = this;
   this.pc.createOffer(function(offer) {
     util.log('Created offer.');
+    // Firefox currently does not support multiplexing once an offer is made.
+    self.firefoxSingular = true;
+
     self.pc.setLocalDescription(offer, function() {
       util.log('Set localDescription to offer');
       self._socket.send({
@@ -287,7 +290,11 @@ ConnectionManager.prototype.connect = function(options) {
 
   var dc;
   if (!!this.pc && !this._lock) {
-    dc = this.pc.createDataChannel(options.label, { reliable: false });
+    var reliable = util.browserisms === 'Firefox' ? !!options.reliable : false;
+    dc = this.pc.createDataChannel(options.label, { reliable: reliable });
+    if (util.browserisms === 'Firefox') {
+      this._makeOffer();
+    }
   }
   var connection = new DataConnection(this.peer, dc, options);
   this._attachConnectionListeners(connection);

+ 1 - 1
lib/dataconnection.js

@@ -39,7 +39,7 @@ DataConnection.prototype._configureDataChannel = function() {
   };
 
   // Reliable.
-  if (this._isReliable) {
+  if (this._isReliable && util.browserisms !== 'Firefox') {
     this._reliable = new Reliable(this._dc, util.debug);
   }
 

+ 9 - 0
lib/peer.js

@@ -246,6 +246,15 @@ Peer.prototype.connect = function(peer, options) {
   }, options);
 
   var manager = this.managers[peer];
+
+  // Firefox currently does not support multiplexing once an offer is made.
+  if (util.browserisms === 'Firefox' && !!manager && manager.firefoxSingular) {
+    var err = new Error('Firefox currently does not support multiplexing after a DataChannel has already been established');
+    err.type = 'firefoxism';
+    this.emit('error', err);
+    return;
+  }
+
   if (!manager) {
     manager = new ConnectionManager(this.id, peer, this._socket, options);
     this._attachManagerListeners(manager);