Server freed from ResourceManager
Commit amended to revert OpenRGBInterfaces.h header (may reconsider in the future) by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
a6bc30a31c
commit
02ba8a799e
3 changed files with 29 additions and 6 deletions
|
|
@ -7,7 +7,6 @@
|
|||
\*-----------------------------------------*/
|
||||
|
||||
#include "NetworkServer.h"
|
||||
#include "ResourceManager.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifndef WIN32
|
||||
|
|
@ -40,6 +39,7 @@ NetworkServer::NetworkServer(std::vector<RGBController *>& control) : controller
|
|||
server_online = false;
|
||||
server_listening = false;
|
||||
ConnectionThread = nullptr;
|
||||
profile_manager = nullptr;
|
||||
}
|
||||
|
||||
NetworkServer::~NetworkServer()
|
||||
|
|
@ -683,7 +683,10 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
ResourceManager::get()->GetProfileManager()->SaveProfile(data);
|
||||
if(profile_manager)
|
||||
{
|
||||
profile_manager->SaveProfile(data);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
@ -693,9 +696,12 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
ResourceManager::get()->GetProfileManager()->LoadProfile(data);
|
||||
if(profile_manager)
|
||||
{
|
||||
profile_manager->LoadProfile(data);
|
||||
}
|
||||
|
||||
for(RGBController* controller : ResourceManager::get()->GetRGBControllers())
|
||||
for(RGBController* controller : controllers)
|
||||
{
|
||||
controller->UpdateLEDs();
|
||||
}
|
||||
|
|
@ -708,7 +714,10 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
ResourceManager::get()->GetProfileManager()->DeleteProfile(data);
|
||||
if(profile_manager)
|
||||
{
|
||||
profile_manager->DeleteProfile(data);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -876,7 +885,10 @@ void NetworkServer::SendRequest_DeviceListChanged(SOCKET client_sock)
|
|||
|
||||
void NetworkServer::SendReply_ProfileList(SOCKET client_sock)
|
||||
{
|
||||
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
if(!profile_manager)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NetPacketHeader reply_hdr;
|
||||
unsigned char *reply_data = profile_manager->GetProfileListDescription();
|
||||
|
|
@ -897,3 +909,8 @@ void NetworkServer::SendReply_ProfileList(SOCKET client_sock)
|
|||
send(client_sock, (const char *)reply_data, reply_size, 0);
|
||||
}
|
||||
|
||||
void NetworkServer::SetProfileManager(ProfileManagerInterface* profile_manager_pointer)
|
||||
{
|
||||
profile_manager = profile_manager_pointer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "RGBController.h"
|
||||
#include "NetworkProtocol.h"
|
||||
#include "net_port.h"
|
||||
#include "ProfileManager.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
|
@ -68,6 +69,8 @@ public:
|
|||
void SendRequest_DeviceListChanged(SOCKET client_sock);
|
||||
void SendReply_ProfileList(SOCKET client_sock);
|
||||
|
||||
void SetProfileManager(ProfileManagerInterface* profile_manager_pointer);
|
||||
|
||||
protected:
|
||||
unsigned short port_num;
|
||||
bool server_online;
|
||||
|
|
@ -87,6 +90,8 @@ protected:
|
|||
std::vector<NetServerCallback> ServerListeningChangeCallbacks;
|
||||
std::vector<void *> ServerListeningChangeCallbackArgs;
|
||||
|
||||
ProfileManagerInterface* profile_manager;
|
||||
|
||||
private:
|
||||
#ifdef WIN32
|
||||
WSADATA wsa;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ ResourceManager::ResourceManager()
|
|||
| Load sizes list from file |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
profile_manager = new ProfileManager(GetConfigurationDirectory());
|
||||
server->SetProfileManager(profile_manager);
|
||||
rgb_controllers_sizes = profile_manager->LoadProfileToList("sizes", true);
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue