diff --git a/meshuser.js b/meshuser.js index e8c4d442..79728183 100644 --- a/meshuser.js +++ b/meshuser.js @@ -4478,16 +4478,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use }); break; } - case 'trafficstats': { - try { ws.send(JSON.stringify({ action: 'trafficstats', stats: parent.getTrafficStats() })); } catch (ex) { } - break; - } - case 'trafficdelta': { - const stats = parent.getTrafficDelta(obj.trafficStats); - obj.trafficStats = stats.current; - try { ws.send(JSON.stringify({ action: 'trafficdelta', delta: stats.delta })); } catch (ex) { } - break; - } case 'getDeviceDetails': { if ((common.validateStrArray(command.nodeids, 1) == false) && (command.nodeids != null)) break; // Check nodeids if (common.validateString(command.type, 3, 4) == false) break; // Check type @@ -4898,6 +4888,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use 'serverversion': serverCommandServerVersion, 'setClip': serverCommandSetClip, 'smsuser': serverCommandSmsUser, + 'trafficdelta': serverCommandTrafficDelta, + 'trafficstats': serverCommandtrafficStats, 'updateUserImage': serverCommandUpdateUserImage, 'urlargs': serverCommandUrlArgs, 'users': serverCommandUsers, @@ -6078,6 +6070,16 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use }); } + function serverCommandTrafficDelta(command) { + const stats = parent.getTrafficDelta(obj.trafficStats); + obj.trafficStats = stats.current; + try { ws.send(JSON.stringify({ action: 'trafficdelta', delta: stats.delta })); } catch (ex) { } + } + + function serverCommandtrafficStats(command) { + try { ws.send(JSON.stringify({ action: 'trafficstats', stats: parent.getTrafficStats() })); } catch (ex) { } + } + function serverCommandUpdateUserImage(command) { if (req.session.loginToken != null) return; // Do not allow this command when logged in using a login token