prevent missing key errors
This commit is contained in:
parent
f18f8645b4
commit
08957a0aa6
@ -345,7 +345,7 @@ PeerServer.prototype._processOutstanding = function(key, id) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PeerServer.prototype._removePeer = function(key, id) {
|
PeerServer.prototype._removePeer = function(key, id) {
|
||||||
if (this._clients[key][id]) {
|
if (this._clients[key] && this._clients[key][id]) {
|
||||||
this._ips[this._clients[key][id].ip]--;
|
this._ips[this._clients[key][id].ip]--;
|
||||||
delete this._clients[key][id];
|
delete this._clients[key][id];
|
||||||
}
|
}
|
||||||
@ -405,6 +405,9 @@ PeerServer.prototype._handleTransmission = function(key, message) {
|
|||||||
|
|
||||||
PeerServer.prototype._generateClientId = function(key) {
|
PeerServer.prototype._generateClientId = function(key) {
|
||||||
var clientId = util.randomId();
|
var clientId = util.randomId();
|
||||||
|
if (!this._clients[key]) {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
while (!!this._clients[key][clientId]) {
|
while (!!this._clients[key][clientId]) {
|
||||||
clientId = util.randomId();
|
clientId = util.randomId();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user