Add --disable-polling for hosting multiple servers on 1 machine

Only 1 instance of STK server needs keep polling the addon server,
the rest can be run with the above option
This commit is contained in:
Benau 2018-07-07 12:50:04 +08:00
parent efd20966e4
commit b6edc0d93f
3 changed files with 6 additions and 3 deletions

View File

@ -598,6 +598,7 @@ void cmdLineHelp()
" --login=s Automatically log in (set the login).\n"
" --password=s Automatically log in (set the password).\n"
" --init-user Save the above login and password (if set) in config.\n"
" --disable-polling Don't poll for logged in user.\n"
" --port=n Port number to use.\n"
" --disable-lan Disable LAN detection (connect using WAN).\n"
" --auto-connect Automatically connect to fist server and start race\n"
@ -1132,7 +1133,8 @@ int handleCmdLine()
NetworkConfig::get()->setServerIdFile(
file_manager->getUserConfigFile(s));
}
if(CommandLine::has("--disable-polling"))
Online::RequestManager::m_disable_polling = true;
if(CommandLine::has("--max-players", &n))
UserConfigParams::m_server_max_players=n;
NetworkConfig::get()->

View File

@ -43,7 +43,7 @@ using namespace Online;
namespace Online
{
RequestManager * RequestManager::m_request_manager = NULL;
bool RequestManager::m_disable_polling = false;
// ------------------------------------------------------------------------
/** Deletes the http manager.
*/
@ -299,7 +299,7 @@ namespace Online
if (StateManager::get()->getGameState() == GUIEngine::MENU)
interval = m_menu_polling_interval;
if (m_time_since_poll > interval)
if (!m_disable_polling && m_time_since_poll > interval)
{
m_time_since_poll = 0;
PlayerManager::requestOnlinePoll();

View File

@ -90,6 +90,7 @@ namespace Online
IPERM_ALLOWED = 1,
IPERM_NOT_ALLOWED = 2
};
static bool m_disable_polling;
private:
/** Time passed since the last poll request. */
float m_time_since_poll;