Fixed MeshAgent files session count.
Ylian Saint-Hilaire committed
May 15, 2020 at 15:23 UTC
76d7e3e7a62c5af4fff0eac0ae5e3e61251289c6
1 file changed
+14
-14
agents/meshcore.js
+14
-14
@@ -1612,6 +1612,20 @@ function createMeshCore(agent) {
1612
return;
1613
}
1614
1615
+ // Add the files session to the count to update the server
1616
+ if (this.httprequest.userid != null) {
1617
+ if (tunnelUserCount.files[this.httprequest.userid] == null) { tunnelUserCount.files[this.httprequest.userid] = 1; } else { tunnelUserCount.files[this.httprequest.userid]++; }
1618
+ try { mesh.SendCommand({ action: 'sessions', type: 'files', value: tunnelUserCount.files }); } catch (ex) { }
1619
+ }
1620
+
1621
+ this.end = function () {
1622
+ // Remove the files session from the count to update the server
1623
+ if (this.httprequest.userid != null) {
1624
+ if (tunnelUserCount.files[this.httprequest.userid] != null) { tunnelUserCount.files[this.httprequest.userid]--; if (tunnelUserCount.files[this.httprequest.userid] <= 0) { delete tunnelUserCount.files[this.httprequest.userid]; } }
1625
+ try { mesh.SendCommand({ action: 'sessions', type: 'files', value: tunnelUserCount.files }); } catch (ex) { }
1626
+ }
1627
+ };
1628
+
1629
// Perform notification if needed. Toast messages may not be supported on all platforms.
1630
if (this.httprequest.consent && (this.httprequest.consent & 32)) {
1631
// User Consent Prompt is required
@@ -1677,20 +1691,6 @@ function createMeshCore(agent) {
1691
if (cmd.action == undefined) { return; }
1692
//sendConsoleText('CMD: ' + JSON.stringify(cmd));
1693
1680
- // Add the files session to the count to update the server
1681
- if (this.httprequest.userid != null) {
1682
- if (tunnelUserCount.files[this.httprequest.userid] == null) { tunnelUserCount.files[this.httprequest.userid] = 1; } else { tunnelUserCount.files[this.httprequest.userid]++; }
1683
- try { mesh.SendCommand({ action: 'sessions', type: 'files', value: tunnelUserCount.files }); } catch (ex) { }
1684
- }
1685
-
1686
- this.end = function () {
1687
- // Remove the files session from the count to update the server
1688
- if (this.httprequest.userid != null) {
1689
- if (tunnelUserCount.files[this.httprequest.userid] != null) { tunnelUserCount.files[this.httprequest.userid]--; if (tunnelUserCount.files[this.httprequest.userid] <= 0) { delete tunnelUserCount.files[this.httprequest.userid]; } }
1690
- try { mesh.SendCommand({ action: 'sessions', type: 'files', value: tunnelUserCount.files }); } catch (ex) { }
1691
- }
1692
- };
1693
-
1694
if ((cmd.path != null) && (process.platform != 'win32') && (cmd.path[0] != '/')) { cmd.path = '/' + cmd.path; } // Add '/' to paths on non-windows
1695
//console.log(objToString(cmd, 0, ' '));
1696
switch (cmd.action) {