|
@@ -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. */
|