@browser-network/network
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -137,3 +137,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
maxMessageRateBeforeRude: Infinity, | ||
maxConnections: 10 | ||
maxConnections: 5 | ||
}, config); | ||
@@ -319,9 +319,16 @@ this.switchboardService = new SwitchboardService_1.default({ | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.switchboardService.sendEmptyRequest()]; | ||
case 0: | ||
// Don't even do the request if we've already reached our max, | ||
// Just schedule the next one and be on our way. | ||
if (this.activeConnections.length >= this.config.maxConnections) { | ||
this._switchboardTimeout = setTimeout(function () { return _this.doSwitchboardRequest(); }, this.config.slowSwitchboardRequestInterval); | ||
return [2 /*return*/]; | ||
} | ||
return [4 /*yield*/, this.switchboardService.sendEmptyRequest()]; | ||
case 1: | ||
resp = _a.sent(); | ||
this._emit('switchboard-response', resp); | ||
numOffers = resp.negotiationItems.filter(function (item) { return item.negotiation.type === 'offer'; }).length; | ||
numAnswers = resp.negotiationItems.filter(function (item) { return item.negotiation.type === 'answer'; }).length; | ||
this._emit('connection-process', "received switchboard response with ".concat(numOffers, " offers and ").concat(numAnswers, " answers")); | ||
this._emit('switchboard-response', resp); | ||
newAnswerConnections = resp.negotiationItems.map(function (item) { | ||
@@ -523,2 +530,7 @@ // Create a new answer connection for each foreign offer | ||
case 0: | ||
// We don't care who's around if we've maxed out our connections | ||
if (this.activeConnections.length >= this.config.maxConnections) { | ||
return [2 /*return*/]; | ||
} | ||
// No need to do anything if we're already connected with this person | ||
if (this.getActiveConnectionByAddress(message.address)) { | ||
@@ -525,0 +537,0 @@ return [2 /*return*/]; |
@@ -37,3 +37,4 @@ export declare type NetworkConfig = { | ||
* messages are we willing to accept from a node in one second before we consider them | ||
* to be spamming us? | ||
* to be spamming us? This defaults to Infinity, i.e. nobody will be considered rude | ||
* no matter how frequently they send messages. | ||
*/ | ||
@@ -45,8 +46,7 @@ maxMessageRateBeforeRude: number; | ||
* or a totally connected network where all nodes are connected to all other | ||
* nodes. If this was set to 3, the network would be essentially linear. | ||
* nodes. If this was set to 2, the network would be essentially linear. | ||
* However it also would be highly prone to partitions as geometric shapes would | ||
* appear. Note this includes the ever present 'open connection', so if this is set | ||
* to 2, the node will only want to find one other node to connect with. | ||
* appear. | ||
*/ | ||
maxConnections: number; | ||
}; |
{ | ||
"name": "@browser-network/network", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "A WebRTC based direct peer to peer network in the browser.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1615563
29855