|
@@ -86,6 +86,7 @@ function Peer(id, options) {
|
|
|
} else {
|
|
|
this._retrieveId();
|
|
|
}
|
|
|
+ //
|
|
|
};
|
|
|
|
|
|
util.inherits(Peer, EventEmitter);
|
|
@@ -120,7 +121,7 @@ Peer.prototype._retrieveId = function(cb) {
|
|
|
Peer.prototype._initialize = function(id) {
|
|
|
var self = this;
|
|
|
this.id = id;
|
|
|
- this.socket = new Socket(this.secure, this.options.host, this.options.port, this.options.key, this.id);
|
|
|
+ this.socket = new Socket(this.options.secure, this.options.host, this.options.port, this.options.key, this.id);
|
|
|
this.socket.on('message', function(data) {
|
|
|
self._dispatchMessage(data);
|
|
|
});
|
|
@@ -142,16 +143,16 @@ Peer.prototype._dispatchMessage = function(message) {
|
|
|
case 'OPEN':
|
|
|
this._processQueue();
|
|
|
this.emit('open', this.id);
|
|
|
- break;
|
|
|
+ return;
|
|
|
case 'ERROR':
|
|
|
this._abort('server-error', payload.msg);
|
|
|
- break;
|
|
|
+ return;
|
|
|
case 'ID-TAKEN':
|
|
|
this._abort('unavailable-id', 'ID `'+this.id+'` is taken');
|
|
|
- break;
|
|
|
+ return;
|
|
|
case 'INVALID-KEY':
|
|
|
this._abort('invalid-key', 'API KEY "' + this._key + '" is invalid');
|
|
|
- break;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
var peer = message.src;
|