diff --git a/cli.cpp b/cli.cpp index a1ecd950..d2631316 100644 --- a/cli.cpp +++ b/cli.cpp @@ -928,13 +928,6 @@ void ApplyOptions(DeviceOptions& options, std::vector &rgb_cont } } -void WaitWhileServerOnline(NetworkServer* srv) -{ - while (srv->GetOnline()) - { - std::this_thread::sleep_for(1s); - }; -} unsigned int cli_pre_detection(int argc, char *argv[]) { @@ -1218,14 +1211,6 @@ unsigned int cli_post_detection(int argc, char *argv[]) } } - /*---------------------------------------------------------*\ - | If the server is online, keep running while it is online | - \*---------------------------------------------------------*/ - if(ResourceManager::get()->GetServer()->GetOnline()) - { - WaitWhileServerOnline(ResourceManager::get()->GetServer()); - } - std::this_thread::sleep_for(1s); exit(0); diff --git a/main.cpp b/main.cpp index 3ca69608..e3c5c6ed 100644 --- a/main.cpp +++ b/main.cpp @@ -76,6 +76,14 @@ void InitializeTimerResolutionThreadFunction() } #endif +void WaitWhileServerOnline(NetworkServer* srv) +{ + while (srv->GetOnline()) + { + std::this_thread::sleep_for(1s); + }; +} + /******************************************************************************************\ * * * AttemptLocalConnection * @@ -160,7 +168,10 @@ int main(int argc, char* argv[]) | Process command line arguments before detection | \*---------------------------------------------------------*/ unsigned int ret_flags = RET_FLAG_START_GUI; - ret_flags |= cli_pre_detection(argc, argv); + if (argc != 0) + { + ret_flags = cli_pre_detection(argc, argv); + } /*---------------------------------------------------------*\ | Perform local connection and/or hardware detection if not | @@ -239,6 +250,20 @@ int main(int argc, char* argv[]) } else { - return 0; + if(ret_flags & RET_FLAG_START_SERVER) + { + if(!ResourceManager::get()->GetServer()->GetOnline()) + { + return 1; + } + else + { + WaitWhileServerOnline(ResourceManager::get()->GetServer()); + } + } + else + { + return 0; + } } }