fixed some syntax mistakes.
This commit is contained in:
parent
72998056e0
commit
974f00c996
@ -49,7 +49,7 @@ function PeerServer(options) {
|
|||||||
this._ips = {};
|
this._ips = {};
|
||||||
|
|
||||||
this._setCleanupIntervals();
|
this._setCleanupIntervals();
|
||||||
};
|
}
|
||||||
|
|
||||||
util.inherits(PeerServer, EventEmitter);
|
util.inherits(PeerServer, EventEmitter);
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ PeerServer.prototype._configureWS = function(socket, key, id, token) {
|
|||||||
// Clean up if a Peer sends a LEAVE.
|
// Clean up if a Peer sends a LEAVE.
|
||||||
if (!message.dst) {
|
if (!message.dst) {
|
||||||
self._removePeer(key, id);
|
self._removePeer(key, id);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
// ICE candidates
|
// ICE candidates
|
||||||
case 'CANDIDATE':
|
case 'CANDIDATE':
|
||||||
// Offer or answer between peers.
|
// Offer or answer between peers.
|
||||||
@ -150,11 +150,11 @@ PeerServer.prototype._configureWS = function(socket, key, id, token) {
|
|||||||
util.prettyError('Message unrecognized');
|
util.prettyError('Message unrecognized');
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
throw e;
|
|
||||||
util.log('Invalid message', data);
|
util.log('Invalid message', data);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
PeerServer.prototype._checkKey = function(key, ip, cb) {
|
PeerServer.prototype._checkKey = function(key, ip, cb) {
|
||||||
@ -181,14 +181,14 @@ PeerServer.prototype._checkKey = function(key, ip, cb) {
|
|||||||
} else {
|
} else {
|
||||||
cb('Invalid key provided');
|
cb('Invalid key provided');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/** Initialize HTTP server routes. */
|
/** Initialize HTTP server routes. */
|
||||||
PeerServer.prototype._initializeHTTP = function() {
|
PeerServer.prototype._initializeHTTP = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this._app.use(restify.bodyParser({ mapParams: false }));
|
this._app.use(restify.bodyParser({ mapParams: false }));
|
||||||
this._app.use(restify.queryParser())
|
this._app.use(restify.queryParser());
|
||||||
this._app.use(util.allowCrossDomain);
|
this._app.use(util.allowCrossDomain);
|
||||||
|
|
||||||
// Retrieve guaranteed random ID.
|
// Retrieve guaranteed random ID.
|
||||||
@ -332,7 +332,7 @@ PeerServer.prototype._setCleanupIntervals = function() {
|
|||||||
var keys = Object.keys(self._ips);
|
var keys = Object.keys(self._ips);
|
||||||
for (var i = 0, ii = keys.length; i < ii; i += 1) {
|
for (var i = 0, ii = keys.length; i < ii; i += 1) {
|
||||||
var key = keys[i];
|
var key = keys[i];
|
||||||
if (self._ips[key] == 0) {
|
if (self._ips[key] === 0) {
|
||||||
delete self._ips[key];
|
delete self._ips[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ PeerServer.prototype._handleTransmission = function(key, message) {
|
|||||||
destination.res.write(data);
|
destination.res.write(data);
|
||||||
} else {
|
} else {
|
||||||
// Neither socket no res available. Peer dead?
|
// Neither socket no res available. Peer dead?
|
||||||
throw "Peer dead"
|
throw "Peer dead";
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// This happens when a peer disconnects without closing connections and
|
// This happens when a peer disconnects without closing connections and
|
||||||
|
@ -13,7 +13,7 @@ var util = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
extend: function(dest, source) {
|
extend: function(dest, source) {
|
||||||
source = source || {}
|
source = source || {};
|
||||||
for(var key in source) {
|
for(var key in source) {
|
||||||
if(source.hasOwnProperty(key)) {
|
if(source.hasOwnProperty(key)) {
|
||||||
dest[key] = source[key];
|
dest[key] = source[key];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user