libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
interprocesscommunicator.h
Go to the documentation of this file.
1
23#ifndef INTERPROCESSCOMMUNICATOR_H
24#define INTERPROCESSCOMMUNICATOR_H
25
26#include <string>
27#include <thread>
28#include <vector>
29#include "events/event.h"
31#ifdef _WIN32
32#include <windows.h>
33#else
34#include <sys/un.h>
35#endif
36
37namespace Nickvision::App
38{
43 {
44 public:
51 InterProcessCommunicator(const std::string& id);
66 bool isServer() const;
71 bool isClient() const;
79 bool communicate(const std::vector<std::string>& args, bool exitIfClient = false);
80
81 private:
85 void runServer();
86 bool m_serverRunning;
88 std::thread m_server;
89 std::string m_path;
90#ifdef _WIN32
91 HANDLE m_serverPipe;
92#else
93 struct sockaddr_un m_sockaddr;
94 int m_serverSocket;
95#endif
96 };
97}
98
99#endif //INTERPROCESSCOMMUNICATOR_H
An inter process communicator (server/client).
Definition interprocesscommunicator.h:43
bool communicate(const std::vector< std::string > &args, bool exitIfClient=false)
Communicates to the IPC server instance.
Events::Event< Events::ParamEventArgs< std::vector< std::string > > > & commandReceived()
Gets the event for when a command is received.
InterProcessCommunicator(const std::string &id)
Constructs an InterProcessCommunicator.
bool isServer() const
Gets whether or not this instance is an IPC server.
~InterProcessCommunicator()
Destructs an InterProcessCommunicator.
bool isClient() const
Gets whether or not this instance is an IPC client.
An event that can have handlers subscribe to it, which in turn will be called when the event is invok...
Definition event.h:49
Definition appinfo.h:32