[WIP] 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:
Adam Honse
2026-04-05 21:25:12 -05:00
parent 0aea2499bb
commit 6db73af92b
6 changed files with 161 additions and 73 deletions

View File

@@ -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);
}