mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
work on current client count
This commit is contained in:
parent
8c4fdbb1c6
commit
85a42849a8
2 changed files with 33 additions and 13 deletions
|
@ -19,6 +19,8 @@
|
||||||
#include "OctreeServerConsts.h"
|
#include "OctreeServerConsts.h"
|
||||||
|
|
||||||
OctreeServer* OctreeServer::_instance = NULL;
|
OctreeServer* OctreeServer::_instance = NULL;
|
||||||
|
int OctreeServer::_clientCount = 0;
|
||||||
|
|
||||||
|
|
||||||
void OctreeServer::attachQueryNodeToNode(Node* newNode) {
|
void OctreeServer::attachQueryNodeToNode(Node* newNode) {
|
||||||
if (newNode->getLinkedData() == NULL) {
|
if (newNode->getLinkedData() == NULL) {
|
||||||
|
@ -46,8 +48,7 @@ OctreeServer::OctreeServer(const QByteArray& packet) :
|
||||||
_octreeInboundPacketProcessor(NULL),
|
_octreeInboundPacketProcessor(NULL),
|
||||||
_persistThread(NULL),
|
_persistThread(NULL),
|
||||||
_started(time(0)),
|
_started(time(0)),
|
||||||
_startedUSecs(usecTimestampNow()),
|
_startedUSecs(usecTimestampNow())
|
||||||
_clientCount(0)
|
|
||||||
{
|
{
|
||||||
_instance = this;
|
_instance = this;
|
||||||
}
|
}
|
||||||
|
@ -77,8 +78,7 @@ OctreeServer::~OctreeServer() {
|
||||||
|
|
||||||
delete _jurisdiction;
|
delete _jurisdiction;
|
||||||
_jurisdiction = NULL;
|
_jurisdiction = NULL;
|
||||||
|
qDebug() << "OctreeServer::~OctreeServer()... DONE";
|
||||||
qDebug() << "OctreeServer::run()... DONE";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeServer::initHTTPManager(int port) {
|
void OctreeServer::initHTTPManager(int port) {
|
||||||
|
@ -157,10 +157,16 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
statsString += "Uptime: ";
|
statsString += "Uptime: ";
|
||||||
|
|
||||||
if (hours > 0) {
|
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) {
|
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) {
|
if (seconds > 0) {
|
||||||
statsString += QString().sprintf("%.3f seconds", seconds);
|
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 minutes = (msecsElapsed/(MSECS_PER_MIN)) % MIN_PER_HOUR;
|
||||||
int hours = (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) {
|
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) {
|
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) {
|
if (seconds >= 0) {
|
||||||
statsString += QString().sprintf("%.3f seconds", seconds);
|
statsString += QString().sprintf("%.3f seconds", seconds);
|
||||||
|
@ -236,6 +248,10 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString&
|
||||||
quint64 totalBytesOfColor = OctreePacketData::getTotalBytesOfColor();
|
quint64 totalBytesOfColor = OctreePacketData::getTotalBytesOfColor();
|
||||||
|
|
||||||
const int COLUMN_WIDTH = 10;
|
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")
|
statsString += QString(" Total Clients Connected: %1 clients\r\n\r\n")
|
||||||
.arg(locale.toString((uint)getCurrentClientCount()).rightJustified(COLUMN_WIDTH, ' '));
|
.arg(locale.toString((uint)getCurrentClientCount()).rightJustified(COLUMN_WIDTH, ' '));
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,13 @@ public:
|
||||||
JurisdictionMap* getJurisdiction() { return _jurisdiction; }
|
JurisdictionMap* getJurisdiction() { return _jurisdiction; }
|
||||||
|
|
||||||
int getPacketsPerClientPerInterval() const { return _packetsPerClientPerInterval; }
|
int getPacketsPerClientPerInterval() const { return _packetsPerClientPerInterval; }
|
||||||
int getCurrentClientCount() const { return _clientCount; }
|
int getPacketsPerClientPerSecond() const { return getPacketsPerClientPerInterval() * INTERVALS_PER_SECOND; }
|
||||||
void clientConnected() { _clientCount++; }
|
int getPacketsTotalPerInterval() const { return _packetsTotalPerInterval; }
|
||||||
void clientDisconnected() { _clientCount--; }
|
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 isInitialLoadComplete() const { return (_persistThread) ? _persistThread->isInitialLoadComplete() : true; }
|
||||||
bool isPersistEnabled() const { return (_persistThread) ? true : false; }
|
bool isPersistEnabled() const { return (_persistThread) ? true : false; }
|
||||||
|
@ -102,7 +106,7 @@ protected:
|
||||||
time_t _started;
|
time_t _started;
|
||||||
quint64 _startedUSecs;
|
quint64 _startedUSecs;
|
||||||
|
|
||||||
int _clientCount;
|
static int _clientCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __octree_server__OctreeServer__
|
#endif // __octree_server__OctreeServer__
|
||||||
|
|
Loading…
Reference in a new issue