diff options
author | chriszero <zerov83@gmail.com> | 2014-11-15 19:43:07 +0100 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2014-11-15 19:43:07 +0100 |
commit | 23f9f7712bfa33b5a488a447a6fabe6035cc3240 (patch) | |
tree | 06bbe8e0bc52496c5ad3c41accc7524aa597e670 /SubscriptionManager.h | |
parent | a40adaf76fb1267d38b4c5e6386933ddb2d0d328 (diff) | |
download | vdr-plugin-plex-23f9f7712bfa33b5a488a447a6fabe6035cc3240.tar.gz vdr-plugin-plex-23f9f7712bfa33b5a488a447a6fabe6035cc3240.tar.bz2 |
initial commit
Diffstat (limited to 'SubscriptionManager.h')
-rw-r--r-- | SubscriptionManager.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/SubscriptionManager.h b/SubscriptionManager.h new file mode 100644 index 0000000..a411256 --- /dev/null +++ b/SubscriptionManager.h @@ -0,0 +1,79 @@ +#ifndef SUBSCRIPTIONMANAGER_H +#define SUBSCRIPTIONMANAGER_H + +#include <string> +#include <iostream> +#include <map> +#include <mutex> +#include <sstream> + +#include "player.h" + +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::to_string(m_iPort) + "; Uuid:" + m_sUuid + "; CmdID:" + std::to_string(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 = false; +}; + +} + +#endif // SUBSCRIPTIONMANAGER_H |