summaryrefslogtreecommitdiff
path: root/SubscriptionManager.h
blob: 9d68e3c1c444af86c980c2436e1f61fef2e9d15d (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef SUBSCRIPTIONMANAGER_H
#define SUBSCRIPTIONMANAGER_H

#include <vdr/tools.h>
#include <string>
#include <iostream>
#include <map>
//#include <mutex>
#include <sstream>

namespace plexclient
{

class Subscriber
{
	public:
	int m_iCommandId;
	Subscriber() {};
	Subscriber(std::string protocol, std::string host, int port, std::string uuid, int commandId);
	
	std::string GetUuid() {
		return m_sUuid;
	}
	
	void SendUpdate(std::string msg, bool isNav);
	
	virtual std::string to_string() {
		return "Subscriber-> Host: " + m_sHost + "; Port: " + std::string(itoa(m_iPort)) + "; Uuid:" + m_sUuid + "; CmdID:" + std::string(itoa(m_iCommandId));
	}

private:
	std::string m_sProtocol;
	std::string m_sHost;
	int m_iPort;
	std::string m_sUuid;
	
	int m_iAge;
};
	
	
class SubscriptionManager
{
public:
	static SubscriptionManager& GetInstance() {
		static SubscriptionManager instance;
		return instance;
	}
	void AddSubscriber(Subscriber subs);
	void RemoveSubscriber(std::string uuid);
	std::string GetMsg(std::string commandId);
	void Notify();
	
	private:
	SubscriptionManager();
	//std::mutex mutex;
	std::map<std::string, Subscriber> m_mSubcribers;
};

class ActionManager
{
	public:
	static ActionManager& GetInstance() {
		static ActionManager instance;
		return instance;
	}
	void AddAction(std::string file);
	std::string GetAction();
	bool IsAction();
	
	private:
	ActionManager();
	std::string m_sAction;
	bool m_isAction;
};

}

#endif // SUBSCRIPTIONMANAGER_H