mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 06:25:01 -04:00
Rework server initialization
* Only create server instance if server is actually needed
* Pass initial server host and port through ResourceManager
* Allow setting default server host and port in Server settings
This commit is contained in:
17
cli.cpp
17
cli.cpp
@@ -1269,8 +1269,6 @@ unsigned int cli_pre_detection(int argc, char* argv[])
|
||||
int arg_index = 1;
|
||||
unsigned int cfg_args = 0;
|
||||
unsigned int ret_flags = 0;
|
||||
std::string server_host = OPENRGB_SDK_HOST;
|
||||
unsigned short server_port = OPENRGB_SDK_PORT;
|
||||
bool server_start = false;
|
||||
bool print_help = false;
|
||||
|
||||
@@ -1408,14 +1406,14 @@ unsigned int cli_pre_detection(int argc, char* argv[])
|
||||
\*---------------------------------------------------------*/
|
||||
else if(option == "--server-port")
|
||||
{
|
||||
if (argument != "")
|
||||
if(argument != "")
|
||||
{
|
||||
try
|
||||
{
|
||||
int port = std::stoi(argument);
|
||||
if (port >= 1024 && port <= 65535)
|
||||
if(port >= 1024 && port <= 65535)
|
||||
{
|
||||
server_port = port;
|
||||
ResourceManager::get()->SetDefaultServerPort(port);
|
||||
server_start = true;
|
||||
}
|
||||
else
|
||||
@@ -1446,11 +1444,9 @@ unsigned int cli_pre_detection(int argc, char* argv[])
|
||||
\*---------------------------------------------------------*/
|
||||
else if(option == "--server-host")
|
||||
{
|
||||
if (argument != "")
|
||||
if(argument != "")
|
||||
{
|
||||
std::string host = argument;
|
||||
|
||||
server_host = host;
|
||||
ResourceManager::get()->SetDefaultServerHost(argument);
|
||||
server_start = true;
|
||||
}
|
||||
else
|
||||
@@ -1694,9 +1690,6 @@ unsigned int cli_pre_detection(int argc, char* argv[])
|
||||
|
||||
if(server_start)
|
||||
{
|
||||
NetworkServer * server = ResourceManager::get()->GetServer();
|
||||
server->SetHost(server_host);
|
||||
server->SetPort(server_port);
|
||||
ret_flags |= RET_FLAG_START_SERVER;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user