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

This commit is contained in:
DarthArgus
2016-05-05 16:04:41 +00:00
parent ade6e1f1d0
commit 16c9ba95d0
3 changed files with 19 additions and 8 deletions
@@ -2771,12 +2771,6 @@ void CentralServer::update()
static int loopCount=0;
m_curTime = static_cast<uint32>(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<time_t>(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);
}
@@ -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;
@@ -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