Browse Source

fix linting errors in `peer.js`

Christopher Van 10 years ago
parent
commit
d68e9ac264
1 changed files with 39 additions and 39 deletions
  1. 39 39
      lib/peer.js

+ 39 - 39
lib/peer.js

@@ -92,7 +92,7 @@ function Peer(id, options) {
     this._retrieveId();
   }
   //
-};
+}
 
 util.inherits(Peer, EventEmitter);
 
@@ -110,7 +110,7 @@ Peer.prototype._initializeServerConnection = function() {
   this.socket.on('disconnected', function() {
     // If we haven't explicitly disconnected, emit error and disconnect.
     if (!self.disconnected) {
-      self.emitError('network', 'Lost connection to server.')
+      self.emitError('network', 'Lost connection to server.');
       self.disconnect();
     }
   });
@@ -127,8 +127,8 @@ Peer.prototype._retrieveId = function(cb) {
   var self = this;
   var http = new XMLHttpRequest();
   var protocol = this.options.secure ? 'https://' : 'http://';
-  var url = protocol + this.options.host + ':' + this.options.port
-    + this.options.path + this.options.key + '/id';
+  var url = protocol + this.options.host + ':' + this.options.port +
+    this.options.path + this.options.key + '/id';
   var queryString = '?ts=' + new Date().getTime() + '' + Math.random();
   url += queryString;
 
@@ -138,12 +138,12 @@ Peer.prototype._retrieveId = function(cb) {
     util.error('Error retrieving ID', e);
     var pathError = '';
     if (self.options.path === '/' && self.options.host !== util.CLOUD_HOST) {
-      pathError = ' If you passed in a `path` to your self-hosted PeerServer, '
-        + 'you\'ll also need to pass in that same path when creating a new'
-        + ' Peer.';
+      pathError = ' If you passed in a `path` to your self-hosted PeerServer, ' +
+        'you\'ll also need to pass in that same path when creating a new ' +
+        'Peer.';
     }
     self._abort('server-error', 'Could not get an ID from the server.' + pathError);
-  }
+  };
   http.onreadystatechange = function() {
     if (http.readyState !== 4) {
       return;
@@ -161,7 +161,7 @@ Peer.prototype._retrieveId = function(cb) {
 Peer.prototype._initialize = function(id) {
   this.id = id;
   this.socket.start(this.id, this.options.token);
-}
+};
 
 /** Handles messages from the server. */
 Peer.prototype._handleMessage = function(message) {
@@ -203,7 +203,7 @@ Peer.prototype._handleMessage = function(message) {
       } else {
         // Create a new connection.
         if (payload.type === 'media') {
-          var connection = new MediaConnection(peer, this, {
+          connection = new MediaConnection(peer, this, {
             connectionId: connectionId,
             _payload: payload,
             metadata: payload.metadata
@@ -239,7 +239,7 @@ Peer.prototype._handleMessage = function(message) {
       }
 
       var id = payload.connectionId;
-      var connection = this.getConnection(peer, id);
+      connection = this.getConnection(peer, id);
 
       if (connection && connection.pc) {
         // Pass it on.
@@ -252,7 +252,7 @@ Peer.prototype._handleMessage = function(message) {
       }
       break;
   }
-}
+};
 
 /** Stores messages without a set up connection, to be claimed later. */
 Peer.prototype._storeMessage = function(connectionId, message) {
@@ -260,7 +260,7 @@ Peer.prototype._storeMessage = function(connectionId, message) {
     this._lostMessages[connectionId] = [];
   }
   this._lostMessages[connectionId].push(message);
-}
+};
 
 /** Retrieve messages from lost message store */
 Peer.prototype._getMessages = function(connectionId) {
@@ -271,7 +271,7 @@ Peer.prototype._getMessages = function(connectionId) {
   } else {
     return [];
   }
-}
+};
 
 /**
  * Returns a DataConnection to the specified peer. See documentation for a
@@ -279,17 +279,17 @@ Peer.prototype._getMessages = function(connectionId) {
  */
 Peer.prototype.connect = function(peer, options) {
   if (this.disconnected) {
-    util.warn('You cannot connect to a new Peer because you called '
-        + '.disconnect() on this Peer and ended your connection with the'
-        + ' server. You can create a new Peer to reconnect, or call reconnect'
-        + ' on this peer if you believe its ID to still be available.');
+    util.warn('You cannot connect to a new Peer because you called ' +
+      '.disconnect() on this Peer and ended your connection with the ' +
+      'server. You can create a new Peer to reconnect, or call reconnect ' +
+      'on this peer if you believe its ID to still be available.');
     this.emitError('disconnected', 'Cannot connect to new Peer after disconnecting from server.');
     return;
   }
   var connection = new DataConnection(peer, this, options);
   this._addConnection(peer, connection);
   return connection;
-}
+};
 
 /**
  * Returns a MediaConnection to the specified peer. See documentation for a
@@ -297,9 +297,9 @@ Peer.prototype.connect = function(peer, options) {
  */
 Peer.prototype.call = function(peer, stream, options) {
   if (this.disconnected) {
-    util.warn('You cannot connect to a new Peer because you called '
-        + '.disconnect() on this Peer and ended your connection with the'
-        + ' server. You can create a new Peer to reconnect.');
+    util.warn('You cannot connect to a new Peer because you called ' +
+      '.disconnect() on this Peer and ended your connection with the ' +
+      'server. You can create a new Peer to reconnect.');
     this.emitError('disconnected', 'Cannot connect to new Peer after disconnecting from server.');
     return;
   }
@@ -312,7 +312,7 @@ Peer.prototype.call = function(peer, stream, options) {
   var call = new MediaConnection(peer, this, options);
   this._addConnection(peer, call);
   return call;
-}
+};
 
 /** Add a data/media connection to this peer. */
 Peer.prototype._addConnection = function(peer, connection) {
@@ -320,7 +320,7 @@ Peer.prototype._addConnection = function(peer, connection) {
     this.connections[peer] = [];
   }
   this.connections[peer].push(connection);
-}
+};
 
 /** Retrieve a data/media connection for this peer. */
 Peer.prototype.getConnection = function(peer, id) {
@@ -334,14 +334,14 @@ Peer.prototype.getConnection = function(peer, id) {
     }
   }
   return null;
-}
+};
 
 Peer.prototype._delayedAbort = function(type, message) {
   var self = this;
   util.setZeroTimeout(function(){
     self._abort(type, message);
   });
-}
+};
 
 /**
  * Destroys the Peer and emits an error message.
@@ -380,7 +380,7 @@ Peer.prototype.destroy = function() {
     this.disconnect();
     this.destroyed = true;
   }
-}
+};
 
 
 /** Disconnects every connection on this peer. */
@@ -392,7 +392,7 @@ Peer.prototype._cleanup = function() {
     }
   }
   this.emit('close');
-}
+};
 
 /** Closes all connections to this peer. */
 Peer.prototype._cleanupPeer = function(peer) {
@@ -400,7 +400,7 @@ Peer.prototype._cleanupPeer = function(peer) {
   for (var j = 0, jj = connections.length; j < jj; j += 1) {
     connections[j].close();
   }
-}
+};
 
 /**
  * Disconnects the Peer's connection to the PeerServer. Does not close any
@@ -422,7 +422,7 @@ Peer.prototype.disconnect = function() {
       self.id = null;
     }
   });
-}
+};
 
 /** Attempts to reconnect with the same ID. */
 Peer.prototype.reconnect = function() {
@@ -452,8 +452,8 @@ Peer.prototype.listAllPeers = function(cb) {
   var self = this;
   var http = new XMLHttpRequest();
   var protocol = this.options.secure ? 'https://' : 'http://';
-  var url = protocol + this.options.host + ':' + this.options.port
-    + this.options.path + this.options.key + '/peers';
+  var url = protocol + this.options.host + ':' + this.options.port +
+    this.options.path + this.options.key + '/peers';
   var queryString = '?ts=' + new Date().getTime() + '' + Math.random();
   url += queryString;
 
@@ -462,7 +462,7 @@ Peer.prototype.listAllPeers = function(cb) {
   http.onerror = function(e) {
     self._abort('server-error', 'Could not get peers from the server.');
     cb([]);
-  }
+  };
   http.onreadystatechange = function() {
     if (http.readyState !== 4) {
       return;
@@ -470,14 +470,14 @@ Peer.prototype.listAllPeers = function(cb) {
     if (http.status === 401) {
       var helpfulError = '';
       if (self.options.host !== util.CLOUD_HOST) {
-        helpfulError = 'It looks like you\'re using the cloud server. You can email '
-          + 'team@peerjs.com to enable peer listing for your API key.';
+        helpfulError = 'It looks like you\'re using the cloud server. You can email ' +
+          'team@peerjs.com to enable peer listing for your API key.';
       } else {
-        helpfulError = 'You need to enable `allow_discovery` on your self-hosted'
-          + ' PeerServer to use this feature.';
+        helpfulError = 'You need to enable `allow_discovery` on your self-hosted ' +
+          'PeerServer to use this feature.';
       }
-      throw new Error('It doesn\'t look like you have permission to list peers IDs. ' + helpfulError);
       cb([]);
+      throw new Error('It doesn\'t look like you have permission to list peers IDs. ' + helpfulError);
     } else if (http.status !== 200) {
       cb([]);
     } else {
@@ -485,6 +485,6 @@ Peer.prototype.listAllPeers = function(cb) {
     }
   };
   http.send(null);
-}
+};
 
 exports.Peer = Peer;