diff --git a/ProfileManager.cpp b/ProfileManager.cpp
index ac9dec057..d8c9c94a2 100644
--- a/ProfileManager.cpp
+++ b/ProfileManager.cpp
@@ -911,7 +911,12 @@ void ProfileManager::SetActiveProfile(std::string profile_name)
{
active_profile = profile_name;
- ResourceManager::get()->GetServer()->SendRequest_ProfileManager_ActiveProfileChanged(active_profile);
+ NetworkServer* server = ResourceManager::get()->GetServer();
+
+ if(server)
+ {
+ server->SendRequest_ProfileManager_ActiveProfileChanged(active_profile);
+ }
SignalProfileManagerUpdate(PROFILEMANAGER_UPDATE_REASON_ACTIVE_PROFILE_CHANGED);
}
@@ -969,7 +974,12 @@ void ProfileManager::SetProfileListFromDescription(unsigned int /*data_size*/, c
void ProfileManager::SignalProfileManagerUpdate(unsigned int update_reason)
{
- ResourceManager::get()->GetServer()->SignalProfileManagerUpdate(update_reason);
+ NetworkServer* server = ResourceManager::get()->GetServer();
+
+ if(server)
+ {
+ server->SignalProfileManagerUpdate(update_reason);
+ }
ProfileManagerCallbackMutex.lock();
@@ -1355,7 +1365,12 @@ bool ProfileManager::LoadProfileWithOptions
plugin_manager->OnProfileAboutToLoad();
}
- ResourceManager::get()->GetServer()->ProfileManager_ProfileAboutToLoad();
+ NetworkServer* server = ResourceManager::get()->GetServer();
+
+ if(server)
+ {
+ server->ProfileManager_ProfileAboutToLoad();
+ }
/*-------------------------------------------------*\
| Get the list of controllers from the resource |
@@ -1384,14 +1399,20 @@ bool ProfileManager::LoadProfileWithOptions
/*-------------------------------------------------*\
| Notify local client |
\*-------------------------------------------------*/
- ResourceManager::get()->GetServer()->SendRequest_ProfileManager_ProfileLoaded(profile_json.dump());
+ if(server)
+ {
+ server->SendRequest_ProfileManager_ProfileLoaded(profile_json.dump());
+ }
/*-------------------------------------------------*\
| Update active profile |
\*-------------------------------------------------*/
SetActiveProfile(profile_name);
- ResourceManager::get()->GetServer()->SendRequest_ProfileManager_ActiveProfileChanged(active_profile);
+ if(server)
+ {
+ server->SendRequest_ProfileManager_ActiveProfileChanged(active_profile);
+ }
return(true);
}
diff --git a/ResourceManager.cpp b/ResourceManager.cpp
index 7bc6066a5..b3dda02cb 100644
--- a/ResourceManager.cpp
+++ b/ResourceManager.cpp
@@ -135,6 +135,9 @@ ResourceManager::ResourceManager()
detection_enabled = true;
init_finished = false;
plugin_manager = NULL;
+ server = NULL;
+ server_host = OPENRGB_SDK_HOST;
+ server_port = OPENRGB_SDK_PORT;
SetupConfigurationDirectory();
@@ -150,44 +153,10 @@ ResourceManager::ResourceManager()
\*-----------------------------------------------------*/
LogManager::get()->configure(settings_manager->GetSettings("LogManager"), GetConfigurationDirectory());
- /*-----------------------------------------------------*\
- | Initialize Server Instance |
- | If configured, pass through full controller list |
- | including clients. Otherwise, pass only local |
- | hardware controllers |
- \*-----------------------------------------------------*/
- json server_settings = settings_manager->GetSettings("Server");
- bool legacy_workaround = false;
-
- server = new NetworkServer();
-
- /*-----------------------------------------------------*\
- | Set server name |
- \*-----------------------------------------------------*/
- std::string titleString = "OpenRGB ";
- titleString.append(VERSION_STRING);
-
- server->SetName(titleString);
- server->SetSettingsManager(settings_manager);
-
- /*-----------------------------------------------------*\
- | Enable legacy SDK workaround in server if configured |
- \*-----------------------------------------------------*/
- if(server_settings.contains("legacy_workaround"))
- {
- legacy_workaround = server_settings["legacy_workaround"];
- }
-
- if(legacy_workaround)
- {
- server->SetLegacyWorkaroundEnable(true);
- }
-
/*-----------------------------------------------------*\
| Load sizes list from file |
\*-----------------------------------------------------*/
profile_manager = new ProfileManager(GetConfigurationDirectory());
- server->SetProfileManager(profile_manager);
}
ResourceManager::~ResourceManager()
@@ -269,7 +238,21 @@ void ResourceManager::SetConfigurationDirectory(const filesystem::path &director
void ResourceManager::SetPluginManager(PluginManagerInterface* plugin_manager_ptr)
{
plugin_manager = plugin_manager_ptr;
- server->SetPluginManager(plugin_manager);
+
+ if(server)
+ {
+ server->SetPluginManager(plugin_manager);
+ }
+}
+
+void ResourceManager::SetServerHost(std::string new_server_host)
+{
+ server_host = new_server_host;
+}
+
+void ResourceManager::SetServerPort(unsigned short new_server_port)
+{
+ server_port = new_server_port;
}
/*---------------------------------------------------------*\
@@ -494,21 +477,24 @@ void ResourceManager::UpdateDeviceList()
/*-----------------------------------------------------*\
| Update server list |
\*-----------------------------------------------------*/
- json server_settings = settings_manager->GetSettings("Server");
- bool all_controllers = false;
+ if(server)
+ {
+ json server_settings = settings_manager->GetSettings("Server");
+ bool all_controllers = false;
- if(server_settings.contains("all_controllers"))
- {
- all_controllers = server_settings["all_controllers"];
- }
+ if(server_settings.contains("all_controllers"))
+ {
+ all_controllers = server_settings["all_controllers"];
+ }
- if(all_controllers)
- {
- server->SetControllers(rgb_controllers);
- }
- else
- {
- server->SetControllers(rgb_controllers_hw);
+ if(all_controllers)
+ {
+ server->SetControllers(rgb_controllers);
+ }
+ else
+ {
+ server->SetControllers(rgb_controllers_hw);
+ }
}
/*-----------------------------------------------------*\
@@ -532,7 +518,10 @@ void ResourceManager::WaitForDetection()
\*---------------------------------------------------------*/
void ResourceManager::SignalResourceManagerUpdate(unsigned int update_reason)
{
- server->SignalResourceManagerUpdate(update_reason);
+ if(server)
+ {
+ server->SignalResourceManagerUpdate(update_reason);
+ }
ResourceManagerCallbackMutex.lock();
@@ -729,8 +718,9 @@ void ResourceManager::Initialize(bool tryConnect, bool detectDevices, bool start
\*-----------------------------------------------------*/
if(start_server)
{
- GetServer()->StartServer();
- if(!GetServer()->GetOnline())
+ InitializeServer();
+ server->StartServer();
+ if(!server->GetOnline())
{
LOG_DEBUG("[%s] Server failed to start", RESOURCEMANAGER);
}
@@ -760,6 +750,52 @@ void ResourceManager::Initialize(bool tryConnect, bool detectDevices, bool start
init_finished = true;
}
+void ResourceManager::InitializeServer()
+{
+ /*-----------------------------------------------------*\
+ | Initialize Server Instance |
+ | If configured, pass through full controller list |
+ | including clients. Otherwise, pass only local |
+ | hardware controllers |
+ \*-----------------------------------------------------*/
+ json server_settings = settings_manager->GetSettings("Server");
+ bool legacy_workaround = false;
+
+ server = new NetworkServer();
+
+ /*-----------------------------------------------------*\
+ | Set server name |
+ \*-----------------------------------------------------*/
+ std::string titleString = "OpenRGB ";
+ titleString.append(VERSION_STRING);
+
+ server->SetName(titleString);
+ server->SetSettingsManager(settings_manager);
+
+ /*-----------------------------------------------------*\
+ | Enable legacy SDK workaround in server if configured |
+ \*-----------------------------------------------------*/
+ if(server_settings.contains("legacy_workaround"))
+ {
+ legacy_workaround = server_settings["legacy_workaround"];
+ }
+
+ if(legacy_workaround)
+ {
+ server->SetLegacyWorkaroundEnable(true);
+ }
+
+ server->SetProfileManager(profile_manager);
+
+ if(plugin_manager)
+ {
+ server->SetPluginManager(plugin_manager);
+ }
+
+ server->SetHost(server_host);
+ server->SetPort(server_port);
+}
+
void ResourceManager::WaitForInitialization()
{
/*-----------------------------------------------------*\
diff --git a/ResourceManager.h b/ResourceManager.h
index 4135dd8f6..8d4557485 100644
--- a/ResourceManager.h
+++ b/ResourceManager.h
@@ -62,6 +62,8 @@ public:
void SetConfigurationDirectory(const filesystem::path &directory);
void SetPluginManager(PluginManagerInterface* plugin_manager_ptr);
+ void SetServerHost(std::string server_host);
+ void SetServerPort(unsigned short server_port);
/*-----------------------------------------------------*\
| Network Client Registration |
@@ -99,6 +101,7 @@ public:
void SignalResourceManagerUpdate(unsigned int update_reason);
void Initialize(bool tryConnect, bool detectDevices, bool startServer, bool applyPostOptions);
+ void InitializeServer();
void WaitForInitialization();
@@ -170,6 +173,8 @@ private:
| Network Server |
\*-----------------------------------------------------*/
NetworkServer* server;
+ std::string server_host;
+ unsigned short server_port;
/*-----------------------------------------------------*\
| Network Clients |
diff --git a/cli.cpp b/cli.cpp
index 8af0194f9..b11e8836a 100644
--- a/cli.cpp
+++ b/cli.cpp
@@ -1408,14 +1408,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()->SetServerPort(port);
server_start = true;
}
else
@@ -1446,11 +1446,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()->SetServerHost(argument);
server_start = true;
}
else
@@ -1694,9 +1692,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;
}
diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp
index a11c55dd4..26dfb5356 100644
--- a/qt/OpenRGBDialog/OpenRGBDialog.cpp
+++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp
@@ -364,7 +364,7 @@ OpenRGBDialog::OpenRGBDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui::
/*-----------------------------------------------------*\
| Add Server Tab |
\*-----------------------------------------------------*/
- AddServerTab();
+ //AddServerTab();
/*-----------------------------------------------------*\
| Add the Software Info page |
diff --git a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui
index 497744812..d7666dad5 100644
--- a/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui
+++ b/qt/OpenRGBSettingsPage/OpenRGBSettingsPage.ui
@@ -23,9 +23,9 @@
0
- 0
+ -746
516
- 1262
+ 1327
@@ -220,17 +220,48 @@
Server
- -
+
-
+
+
+ 127.0.0.1
+
+
+
+ -
+
+
+ Server Host
+
+
+
+ -
+
+
+ Legacy Workaround
+
+
+
+ -
Serve All Devices (Including those from client connections)
- -
-
+
-
+
- Legacy Workaround
+ Server Port
+
+
+
+ -
+
+
+ 65535
+
+
+ 6742