Move network server to resource manager
This commit is contained in:
parent
90e6ba88f1
commit
c1ac870035
3 changed files with 47 additions and 8 deletions
|
|
@ -25,6 +25,11 @@ ResourceManager::ResourceManager()
|
|||
detection_string = "";
|
||||
detection_is_required = false;
|
||||
DetectDevicesThread = nullptr;
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Initialize Server Instance |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
server = new NetworkServer(rgb_controllers);
|
||||
}
|
||||
|
||||
ResourceManager::~ResourceManager()
|
||||
|
|
@ -91,6 +96,11 @@ void ResourceManager::DeviceListChanged()
|
|||
DeviceListChangeMutex.unlock();
|
||||
}
|
||||
|
||||
NetworkServer* ResourceManager::GetServer()
|
||||
{
|
||||
return(server);
|
||||
}
|
||||
|
||||
unsigned int ResourceManager::GetDetectionPercent()
|
||||
{
|
||||
return (detection_percent.load());
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include <string>
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
#include "NetworkClient.h"
|
||||
#include "NetworkServer.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
typedef std::function<void(std::vector<i2c_smbus_interface*>&)> I2CBusDetectorFunction;
|
||||
|
|
@ -37,6 +39,7 @@ public:
|
|||
|
||||
unsigned int GetDetectionPercent();
|
||||
const char* GetDetectionString();
|
||||
NetworkServer* GetServer();
|
||||
|
||||
void DeviceListChanged();
|
||||
|
||||
|
|
@ -53,22 +56,49 @@ public:
|
|||
private:
|
||||
static std::unique_ptr<ResourceManager> instance;
|
||||
|
||||
std::atomic<bool> detection_is_required;
|
||||
std::atomic<unsigned int> detection_percent;
|
||||
const char* detection_string;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| I2C/SMBus Interfaces |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::vector<i2c_smbus_interface*> busses;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| RGBControllers |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
//std::vector<RGBController*> rgb_controllers_hw;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Network Server |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
NetworkServer* server;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Network Clients |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
//std::vector<NetworkClient*> clients;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detectors |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::vector<DeviceDetectorFunction> device_detectors;
|
||||
std::vector<std::string> device_detector_strings;
|
||||
std::vector<I2CBusDetectorFunction> i2c_bus_detectors;
|
||||
std::vector<I2CDeviceDetectorFunction> i2c_device_detectors;
|
||||
std::vector<std::string> i2c_device_detector_strings;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detection Thread and Detection State |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::thread * DetectDevicesThread;
|
||||
|
||||
std::mutex DetectDeviceMutex;
|
||||
|
||||
std::atomic<bool> detection_is_required;
|
||||
std::atomic<unsigned int> detection_percent;
|
||||
const char* detection_string;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Device List Changed Callback |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::mutex DeviceListChangeMutex;
|
||||
std::vector<ResourceManagerCallback> DeviceListChangeCallbacks;
|
||||
std::vector<void *> DeviceListChangeCallbackArgs;
|
||||
|
|
|
|||
5
main.cpp
5
main.cpp
|
|
@ -150,7 +150,6 @@ int main(int argc, char* argv[])
|
|||
std::vector<RGBController*> &rgb_controllers = ResourceManager::get()->GetRGBControllers();
|
||||
|
||||
ProfileManager profile_manager(rgb_controllers);
|
||||
NetworkServer server(rgb_controllers);
|
||||
|
||||
if(!AttemptLocalConnection(rgb_controllers))
|
||||
{
|
||||
|
|
@ -163,7 +162,7 @@ int main(int argc, char* argv[])
|
|||
unsigned int ret_flags = RET_FLAG_START_GUI;
|
||||
if(argc > 1)
|
||||
{
|
||||
ret_flags = cli_main(argc, argv, rgb_controllers, &profile_manager, &server, clients);
|
||||
ret_flags = cli_main(argc, argv, rgb_controllers, &profile_manager, ResourceManager::get()->GetServer(), clients);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
|
|
@ -185,7 +184,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if(clients.size() == 0)
|
||||
{
|
||||
dlg.AddServerTab(&server);
|
||||
dlg.AddServerTab(ResourceManager::get()->GetServer());
|
||||
}
|
||||
|
||||
dlg.AddClientTab();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue