2017-01-27 16:45:01 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class IPCHandler : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Utils::Slot<void(std::string)> Callback;
|
|
|
|
|
|
|
|
IPCHandler();
|
|
|
|
~IPCHandler();
|
|
|
|
|
|
|
|
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
|
|
|
|
const char* getName() override { return "IPCHandler"; };
|
|
|
|
#endif
|
|
|
|
|
2017-01-27 17:09:32 -05:00
|
|
|
static void SendWorker(std::string message, std::string data);
|
|
|
|
static void SendClient(std::string message, std::string data);
|
2017-01-27 16:45:01 -05:00
|
|
|
|
2017-01-27 17:09:32 -05:00
|
|
|
static void OnWorker(std::string message, Callback callback);
|
|
|
|
static void OnClient(std::string message, Callback callback);
|
2017-01-27 16:45:01 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
static std::unique_ptr<Utils::IPC::BidirectionalChannel> WorkerChannel;
|
|
|
|
static std::unique_ptr<Utils::IPC::BidirectionalChannel> ClientChannel;
|
|
|
|
|
|
|
|
static std::unordered_map<std::string, Callback> WorkerCallbacks;
|
|
|
|
static std::unordered_map<std::string, Callback> ClientCallbacks;
|
|
|
|
|
|
|
|
static void InitChannels();
|
|
|
|
static void StartWorker();
|
2017-01-27 17:09:32 -05:00
|
|
|
|
|
|
|
static void HandleClient();
|
|
|
|
static void HandleWorker();
|
2017-01-27 16:45:01 -05:00
|
|
|
};
|
|
|
|
}
|