summaryrefslogtreecommitdiff
path: root/src/IPC.h
blob: e0bbceea5f80a7aa3d726d88bbcffb72a9f22c0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <sys/socket.h>
#include <sys/un.h>

#include "commands.h"
#include "config.h"
#include "util.h"

class IPCServerModule
{
public:
	IPCServerModule(CommandsModule& commandsModule, Config& cfg, Globals& globals);
	void init();
	void doListen();
	void quitIPC();
	int getFD();
private:
	CommandsModule& commandsModule;
	Config& cfg;
	Globals& globals;
	int sockfd;
	int len;
	bool first = true;
	bool ready = false;
	sockaddr_un address;
};

class IPCClientModule
{
public:
	IPCClientModule();

	// Returns 0 for success, 1 for X error, -1 for socket error
	int init();
	
	// Returns 0 for success, 1 for not ready, -1 for socket error
	int sendMessage(const char* message, int length);

	// Returns 0 for success, 1 for not ready, -1 for socket error
	int getMessage(char* buff, int buffsize);

	
	void quit();
private:
	bool ready;
	int sockfd;
};