Permalink
Browse files

abstraction issues

  • Loading branch information...
1 parent d62aed6 commit 6277022009d396bf67e25370c3f2ba7310e1c8b7 @michelle michelle committed Mar 24, 2013
Showing with 31 additions and 31 deletions.
  1. +15 −15 dist/peer.js
  2. +1 −1 dist/peer.min.js
  3. +14 −13 lib/connectionmanager.js
  4. +1 −2 lib/peer.js
View
@@ -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. */
Oops, something went wrong.

0 comments on commit 6277022

Please sign in to comment.