Explorar el Código

abstraction issues

Michelle Bu hace 12 años
padre
commit
6277022009
Se han modificado 4 ficheros con 30 adiciones y 30 borrados
  1. 15 15
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 14 13
      lib/connectionmanager.js
  4. 1 2
      lib/peer.js

+ 15 - 15
dist/peer.js

@@ -1366,8 +1366,7 @@ Peer.prototype.connect = function(peer, options) {
   }
 
   options = util.extend({
-    config: this._options.config,
-    label: 'peerjs'
+    config: this._options.config
   }, options);
 
   var manager = this.managers[peer];
@@ -1791,36 +1790,37 @@ ConnectionManager.prototype.close = function() {
 };
 
 /** Create and returns a DataConnection with the peer with the given label. */
-ConnectionManager.prototype.connect = function(label, options) {
+ConnectionManager.prototype.connect = function(label) {
   if (!this.open) {
     return;
   }
-  // Check if label is taken...if so, generate a new label randomly.
-  while (!!this.connections[label]) {
-    label = 'peerjs' + this._default;
-    this._default += 1;
-  }
 
-  options = util.extend({
+  var options = {
     reliable: false,
     serialization: 'binary',
-    label: label
-  }, options);
+    label: label || 'peerjs'
+  };
+
+  // Check if label is taken...if so, generate a new label randomly.
+  while (!!this.connections[options.label]) {
+    options.label = 'peerjs' + this._default;
+    this._default += 1;
+  }
 
-  this.labels[label] = options;
+  this.labels[options.label] = options;
 
   var dc;
   if (!!this.pc) {
-    dc = this.pc.createDataChannel(label, { reliable: false });
+    dc = this.pc.createDataChannel(options.label, { reliable: false });
   }
   var connection = new DataConnection(this.peer, dc, options);
   this._attachConnectionListeners(connection);
-  this.connections[label] = connection;
+  this.connections[options.label] = connection;
 
   if (!this.pc) {
     this._queued.push(connection);
   }
-  return [label, connection];
+  return [options.label, connection];
 };
 
 /** Updates label:[serialization, reliable, metadata] pairs from offer. */

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
dist/peer.min.js


+ 14 - 13
lib/connectionmanager.js

@@ -251,36 +251,37 @@ ConnectionManager.prototype.close = function() {
 };
 
 /** Create and returns a DataConnection with the peer with the given label. */
-ConnectionManager.prototype.connect = function(label, options) {
+ConnectionManager.prototype.connect = function(label) {
   if (!this.open) {
     return;
   }
-  // Check if label is taken...if so, generate a new label randomly.
-  while (!!this.connections[label]) {
-    label = 'peerjs' + this._default;
-    this._default += 1;
-  }
 
-  options = util.extend({
+  var options = {
     reliable: false,
     serialization: 'binary',
-    label: label
-  }, options);
+    label: label || 'peerjs'
+  };
+
+  // Check if label is taken...if so, generate a new label randomly.
+  while (!!this.connections[options.label]) {
+    options.label = 'peerjs' + this._default;
+    this._default += 1;
+  }
 
-  this.labels[label] = options;
+  this.labels[options.label] = options;
 
   var dc;
   if (!!this.pc) {
-    dc = this.pc.createDataChannel(label, { reliable: false });
+    dc = this.pc.createDataChannel(options.label, { reliable: false });
   }
   var connection = new DataConnection(this.peer, dc, options);
   this._attachConnectionListeners(connection);
-  this.connections[label] = connection;
+  this.connections[options.label] = connection;
 
   if (!this.pc) {
     this._queued.push(connection);
   }
-  return [label, connection];
+  return [options.label, connection];
 };
 
 /** Updates label:[serialization, reliable, metadata] pairs from offer. */

+ 1 - 2
lib/peer.js

@@ -229,8 +229,7 @@ Peer.prototype.connect = function(peer, options) {
   }
 
   options = util.extend({
-    config: this._options.config,
-    label: 'peerjs'
+    config: this._options.config
   }, options);
 
   var manager = this.managers[peer];

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio