34 lines
882 B
C++
34 lines
882 B
C++
|
#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
|
||
|
|
||
|
void SendWorker(std::string message, std::string data);
|
||
|
void SendClient(std::string message, std::string data);
|
||
|
|
||
|
void OnWorker(std::string message, Callback callback);
|
||
|
void OnClient(std::string message, Callback callback);
|
||
|
|
||
|
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();
|
||
|
};
|
||
|
}
|