From 16c9ba95d00ef17d30ff5cee4eb915ab746b2dbd Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 5 May 2016 16:04:41 +0000 Subject: [PATCH] add ConfigCentralServer::getMetricsDataURL() and move the stats collection functionality to the function that sends to the login server; this may or may not be optimal depending on how often it is updated --- .../CentralServer/src/shared/CentralServer.cpp | 18 +++++++++++------- .../src/shared/ConfigCentralServer.cpp | 1 + .../src/shared/ConfigCentralServer.h | 8 +++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.cpp b/engine/server/application/CentralServer/src/shared/CentralServer.cpp index 411bf5b8..700db9f4 100755 --- a/engine/server/application/CentralServer/src/shared/CentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/CentralServer.cpp @@ -2771,12 +2771,6 @@ void CentralServer::update() static int loopCount=0; m_curTime = static_cast(time(0)); - // stella: Adding those for sending regular updates through WebAPI to the webserver - std::string updateURL = "http://webdev/test/asdf/asdf"; //todo: add config vars to CentralServer config header and cpp - - std::ostringstream postBuf; - postBuf << "population=" << CentralServer::getInstance().getPlayerCount(); - // Tell the LoginServers if necessary if ((++loopCount > ConfigCentralServer::getUpdatePlayerCountFrequency())) { @@ -2784,7 +2778,6 @@ void CentralServer::update() // Update the population on the server sendPopulationUpdateToLoginServer(); - webAPI::simplePost(updateURL, std::string(postBuf.str()), ""); } if ( ConfigCentralServer::getAuctionEnabled() ) // allow auctions? @@ -2847,6 +2840,17 @@ void CentralServer::sendPopulationUpdateToLoginServer() if (!isPreloadFinished() || (time(0)-m_lastLoadingStateTime < static_cast(ConfigCentralServer::getRecentLoadingStateSeconds()))) loadedRecently=true; + // stella: Adding those for sending regular updates through WebAPI to the webserver + std::string updateURL = std::string(ConfigCentralServer::getMetricsDataURL()); + + if (!(updateURL.empty())) + { + std::ostringstream postBuf; + postBuf << "totalPlayerCount=" << m_totalPlayerCount << "&totalEmptySceneCount=" << m_totalEmptySceneCount << "&totalFreeTrialCount=" << m_totalFreeTrialCount << "&totalTutorialSceneCount=" << m_totalTutorialSceneCount << "&totalFalconSceneCount=" << m_totalFalconSceneCount; + + webAPI::simplePost(updateURL, std::string(postBuf.str()), ""); + } + UpdatePlayerCountMessage upm(loadedRecently, m_totalPlayerCount, m_totalFreeTrialCount, m_totalEmptySceneCount, m_totalTutorialSceneCount, m_totalFalconSceneCount); sendToAllLoginServers(upm); } diff --git a/engine/server/application/CentralServer/src/shared/ConfigCentralServer.cpp b/engine/server/application/CentralServer/src/shared/ConfigCentralServer.cpp index a13bd448..28a33e2f 100755 --- a/engine/server/application/CentralServer/src/shared/ConfigCentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/ConfigCentralServer.cpp @@ -127,6 +127,7 @@ void ConfigCentralServer::install(void) KEY_BOOL (disconnectDuplicateConnectionsOnOtherGalaxies, false); KEY_BOOL (requestDbSaveOnPlanetServerCrash, true); KEY_INT (maxTimeToWaitForPlanetServerStartSeconds, 5*60); // seconds + KEY_STRING (metricsDataURL, ""); int index = 0; char const * result = 0; diff --git a/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h b/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h index fdc5b131..ed971f33 100755 --- a/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h +++ b/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h @@ -71,6 +71,7 @@ public: bool requestDbSaveOnPlanetServerCrash; int maxTimeToWaitForPlanetServerStartSeconds; + const char * metricsDataURL; }; static const unsigned short getChatServicePort (); @@ -140,7 +141,7 @@ public: static bool getRequestDbSaveOnPlanetServerCrash(); static int getMaxTimeToWaitForPlanetServerStartSeconds(); - + static const char * getMetricsDataURL(); private: static Data * data; }; @@ -510,6 +511,11 @@ inline int ConfigCentralServer::getMaxTimeToWaitForPlanetServerStartSeconds() return data->maxTimeToWaitForPlanetServerStartSeconds; } +inline const char * ConfigCentralServer::getMetricsDataURL() +{ + return data->metricsDataURL; +} + // ====================================================================== #endif // _ConfigCentralServer_H