mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Improved device session notification.
This commit is contained in:
parent
29f08c901b
commit
2b4336e222
4 changed files with 40 additions and 2 deletions
|
@ -304,6 +304,7 @@ function createMeshCore(agent) {
|
|||
var nextTunnelIndex = 1;
|
||||
var amtPolicy = null;
|
||||
var apftunnel = null;
|
||||
var tunnelUserCount = { terminal: {}, files: {} }; // List of userid->count sessions for terminal and files.
|
||||
|
||||
// Add to the server event log
|
||||
function MeshServerLog(msg, state) {
|
||||
|
@ -1154,6 +1155,12 @@ function createMeshCore(agent) {
|
|||
this.httprequest.tpromise = new prom(function (res, rej) { this._res = res; this._rej = rej; });
|
||||
|
||||
this.end = function () {
|
||||
// Remove the terminal session to the count to update the server
|
||||
if (this.httprequest.userid != null) {
|
||||
if (tunnelUserCount.terminal[this.httprequest.userid] != null) { tunnelUserCount.terminal[this.httprequest.userid]--; if (tunnelUserCount.terminal[this.httprequest.userid] <= 0) { delete tunnelUserCount.terminal[this.httprequest.userid]; } }
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'terminal', value: tunnelUserCount.terminal }); } catch (ex) { }
|
||||
}
|
||||
|
||||
if (process.platform == 'win32') {
|
||||
// Unpipe the web socket
|
||||
this.unpipe(this.httprequest._term);
|
||||
|
@ -1315,6 +1322,12 @@ function createMeshCore(agent) {
|
|||
this.httprequest.tpromise._res();
|
||||
}
|
||||
|
||||
// Add the terminal session to the count to update the server
|
||||
if (this.httprequest.userid != null) {
|
||||
if (tunnelUserCount.terminal[this.httprequest.userid] == null) { tunnelUserCount.terminal[this.httprequest.userid] = 1; } else { tunnelUserCount.terminal[this.httprequest.userid]++; }
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'terminal', value: tunnelUserCount.terminal }); } catch (ex) { }
|
||||
}
|
||||
|
||||
this.httprequest.tpromise.that = this;
|
||||
this.httprequest.tpromise.then(function ()
|
||||
{
|
||||
|
@ -1664,6 +1677,20 @@ function createMeshCore(agent) {
|
|||
if (cmd.action == undefined) { return; }
|
||||
//sendConsoleText('CMD: ' + JSON.stringify(cmd));
|
||||
|
||||
// Add the files session to the count to update the server
|
||||
if (this.httprequest.userid != null) {
|
||||
if (tunnelUserCount.files[this.httprequest.userid] == null) { tunnelUserCount.files[this.httprequest.userid] = 1; } else { tunnelUserCount.files[this.httprequest.userid]++; }
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'files', value: tunnelUserCount.files }); } catch (ex) { }
|
||||
}
|
||||
|
||||
this.end = function () {
|
||||
// Remove the files session from the count to update the server
|
||||
if (this.httprequest.userid != null) {
|
||||
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]; } }
|
||||
try { mesh.SendCommand({ action: 'sessions', type: 'files', value: tunnelUserCount.files }); } catch (ex) { }
|
||||
}
|
||||
};
|
||||
|
||||
if ((cmd.path != null) && (process.platform != 'win32') && (cmd.path[0] != '/')) { cmd.path = '/' + cmd.path; } // Add '/' to paths on non-windows
|
||||
//console.log(objToString(cmd, 0, ' '));
|
||||
switch (cmd.action) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue