From 85a42849a81300c0107bab7f41aaa4da9f3d3170 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 26 Feb 2014 20:36:11 -0800 Subject: [PATCH] work on current client count --- assignment-client/src/octree/OctreeServer.cpp | 34 ++++++++++++++----- assignment-client/src/octree/OctreeServer.h | 12 ++++--- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index 743f289dec..f2ebe4a428 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -19,6 +19,8 @@ #include "OctreeServerConsts.h" OctreeServer* OctreeServer::_instance = NULL; +int OctreeServer::_clientCount = 0; + void OctreeServer::attachQueryNodeToNode(Node* newNode) { if (newNode->getLinkedData() == NULL) { @@ -46,8 +48,7 @@ OctreeServer::OctreeServer(const QByteArray& packet) : _octreeInboundPacketProcessor(NULL), _persistThread(NULL), _started(time(0)), - _startedUSecs(usecTimestampNow()), - _clientCount(0) + _startedUSecs(usecTimestampNow()) { _instance = this; } @@ -77,8 +78,7 @@ OctreeServer::~OctreeServer() { delete _jurisdiction; _jurisdiction = NULL; - - qDebug() << "OctreeServer::run()... DONE"; + qDebug() << "OctreeServer::~OctreeServer()... DONE"; } void OctreeServer::initHTTPManager(int port) { @@ -157,10 +157,16 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString& statsString += "Uptime: "; if (hours > 0) { - statsString += QString("%1 hour%2").arg(hours).arg((hours > 1) ? "s" : ""); + statsString += QString("%1 hour").arg(hours); + if (hours > 1) { + statsString += QString("s"); + } } if (minutes > 0) { - statsString += QString("%1 minute%s").arg(minutes).arg((minutes > 1) ? "s" : ""); + statsString += QString("%1 minute").arg(minutes); + if (minutes > 1) { + statsString += QString("s"); + } } if (seconds > 0) { statsString += QString().sprintf("%.3f seconds", seconds); @@ -182,12 +188,18 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString& int minutes = (msecsElapsed/(MSECS_PER_MIN)) % MIN_PER_HOUR; int hours = (msecsElapsed/(MSECS_PER_MIN * MIN_PER_HOUR)); - statsString += QString("%1 File Load Took").arg(getMyServerName()); + statsString += QString("%1 File Load Took ").arg(getMyServerName()); if (hours > 0) { - statsString += QString("%1 hour%2").arg(hours).arg((hours > 1) ? "s" : ""); + statsString += QString("%1 hour").arg(hours); + if (hours > 1) { + statsString += QString("s"); + } } if (minutes > 0) { - statsString += QString("%1 minute%2").arg(minutes).arg((minutes > 1) ? "s" : ""); + statsString += QString("%1 minute").arg(minutes); + if (minutes > 1) { + statsString += QString("s"); + } } if (seconds >= 0) { statsString += QString().sprintf("%.3f seconds", seconds); @@ -236,6 +248,10 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString& quint64 totalBytesOfColor = OctreePacketData::getTotalBytesOfColor(); const int COLUMN_WIDTH = 10; + statsString += QString(" Configured Max PPS/Client: %1 pps/client\r\n") + .arg(locale.toString((uint)getPacketsPerClientPerSecond()).rightJustified(COLUMN_WIDTH, ' ')); + statsString += QString(" Configured Max PPS/Server: %1 pps/server\r\n\r\n") + .arg(locale.toString((uint)getPacketsTotalPerSecond()).rightJustified(COLUMN_WIDTH, ' ')); statsString += QString(" Total Clients Connected: %1 clients\r\n\r\n") .arg(locale.toString((uint)getCurrentClientCount()).rightJustified(COLUMN_WIDTH, ' ')); diff --git a/assignment-client/src/octree/OctreeServer.h b/assignment-client/src/octree/OctreeServer.h index 5c2518fadb..1dcb3352ff 100644 --- a/assignment-client/src/octree/OctreeServer.h +++ b/assignment-client/src/octree/OctreeServer.h @@ -44,9 +44,13 @@ public: JurisdictionMap* getJurisdiction() { return _jurisdiction; } int getPacketsPerClientPerInterval() const { return _packetsPerClientPerInterval; } - int getCurrentClientCount() const { return _clientCount; } - void clientConnected() { _clientCount++; } - void clientDisconnected() { _clientCount--; } + int getPacketsPerClientPerSecond() const { return getPacketsPerClientPerInterval() * INTERVALS_PER_SECOND; } + int getPacketsTotalPerInterval() const { return _packetsTotalPerInterval; } + int getPacketsTotalPerSecond() const { return getPacketsTotalPerInterval() * INTERVALS_PER_SECOND; } + + static int getCurrentClientCount() { return _clientCount; } + static void clientConnected() { _clientCount++; } + static void clientDisconnected() { _clientCount--; } bool isInitialLoadComplete() const { return (_persistThread) ? _persistThread->isInitialLoadComplete() : true; } bool isPersistEnabled() const { return (_persistThread) ? true : false; } @@ -102,7 +106,7 @@ protected: time_t _started; quint64 _startedUSecs; - int _clientCount; + static int _clientCount; }; #endif // __octree_server__OctreeServer__