forked from cory/tildefriends
Only send stats to clients if there is a client watching them.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3846 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
14
core/core.js
14
core/core.js
@ -6,6 +6,7 @@ var app = require("app");
|
||||
var gProcessIndex = 0;
|
||||
var gProcesses = {};
|
||||
var gSessionIndex = 0;
|
||||
var gStatsTimer = false;
|
||||
|
||||
var gGlobalSettings = {
|
||||
index: "/~core/index",
|
||||
@ -157,6 +158,7 @@ async function getProcessBlob(blobId, key, options) {
|
||||
process.lastActive = Date.now();
|
||||
process.lastPing = null;
|
||||
process.timeout = options.timeout;
|
||||
process.stats = false;
|
||||
var resolveReady;
|
||||
var rejectReady;
|
||||
process.ready = new Promise(function(resolve, reject) {
|
||||
@ -548,14 +550,20 @@ async function loadSettings() {
|
||||
}
|
||||
|
||||
function sendStats() {
|
||||
var any = false;
|
||||
for (var process of Object.values(gProcesses)) {
|
||||
if (process.app) {
|
||||
if (process.app && process.stats) {
|
||||
process.app.send({action: 'stats', stats: getStats()});
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
setTimeout(sendStats, 1000);
|
||||
|
||||
if (any) {
|
||||
setTimeout(sendStats, 1000);
|
||||
} else {
|
||||
gStatsTimer = false;
|
||||
}
|
||||
}
|
||||
setTimeout(sendStats, 1000);
|
||||
|
||||
loadSettings().then(function() {
|
||||
var auth = require("auth");
|
||||
|
Reference in New Issue
Block a user