gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

server.h (1259B)


      1 #pragma once
      2 
      3 #include <chrono>
      4 #include <mutex>
      5 #include <list>
      6 #include <condition_variable>
      7 
      8 #include "clientConnection.h"
      9 #include "config.h"
     10 #include "import.h"
     11 #include "romPool.h"
     12 #include "udpServer.h"
     13 #include "networkLib/tcpServer.h"
     14 
     15 namespace bridgeServer
     16 {
     17 	class Server
     18 	{
     19 	public:
     20 		Server(int _argc, char** _argv);
     21 		~Server();
     22 
     23 		void run();
     24 
     25 		void onClientConnected(std::unique_ptr<networkLib::TcpStream> _stream);
     26 		void onClientException(const ClientConnection& _clientConnection, const networkLib::NetException& _e);
     27 
     28 		void exit(bool _exit);
     29 
     30 		auto& getPlugins() { return m_plugins; }
     31 		auto& getRomPool() { return m_romPool; }
     32 
     33 		bridgeLib::DeviceState getCachedDeviceState(const bridgeLib::SessionId& _id);
     34 
     35 	private:
     36 		void cleanupClients();
     37 		void doPeriodicDeviceStateUpdate();
     38 
     39 		Config m_config;
     40 
     41 		Import m_plugins;
     42 		RomPool m_romPool;
     43 
     44 		UdpServer m_udpServer;
     45 		networkLib::TcpServer m_tcpServer;
     46 
     47 		std::mutex m_mutexClients;
     48 		std::list<std::unique_ptr<ClientConnection>> m_clients;
     49 		std::map<bridgeLib::SessionId, bridgeLib::DeviceState> m_cachedDeviceStates;
     50 
     51 		bool m_exit = false;
     52 
     53 		std::mutex m_cvWaitMutex;
     54 		std::condition_variable m_cvWait;
     55 		std::chrono::system_clock::time_point m_lastDeviceStateUpdate;
     56 	};
     57 }