From c927170ea2a83131dd27d3712fc616805c54cc5f Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 10 Sep 2014 18:30:30 +0200 Subject: [PATCH] Fixes to current client stats when timeouts were occurring. --- src/controller/controller_statistics.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index fd861151..05d144c5 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -126,6 +126,8 @@ bool Controller::hasViewers(std::string streamName){ /// ~~~~~~~~~~~~~~~ /// In case of the second method, the response is an array in the same order as the requests. void Controller::fillClients(JSON::Value & req, JSON::Value & rep){ + //memorize the current system time + long long currTime = Util::epoch(); //first, figure out the timestamp wanted long long int reqTime = 0; if (req.isMember("time")){ @@ -187,6 +189,11 @@ void Controller::fillClients(JSON::Value & req, JSON::Value & rep){ //start with current connections if (curConns.size()){ for (std::map::iterator it = curConns.begin(); it != curConns.end(); it++){ + if (!it->second.log.size()){continue;} + //ignore users that haven't been updated in the last 5 seconds. + if (it->second.log.rbegin()->first < currTime - 5){ + continue; + } unsigned long long time = reqTime; if (now){time = it->second.log.rbegin()->first;} //data present and wanted? insert it!