From b6edc0d93f2e4504c36248a97aa3134b2f185f20 Mon Sep 17 00:00:00 2001 From: Benau Date: Sat, 7 Jul 2018 12:50:04 +0800 Subject: [PATCH] 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 --- src/main.cpp | 4 +++- src/online/request_manager.cpp | 4 ++-- src/online/request_manager.hpp | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6119b601e..31bf70828 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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()-> diff --git a/src/online/request_manager.cpp b/src/online/request_manager.cpp index b59221890..4803afad9 100644 --- a/src/online/request_manager.cpp +++ b/src/online/request_manager.cpp @@ -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(); diff --git a/src/online/request_manager.hpp b/src/online/request_manager.hpp index 5457fffc7..8921ae9b9 100644 --- a/src/online/request_manager.hpp +++ b/src/online/request_manager.hpp @@ -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;