12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #ifndef ECNOTIFYMASTER_H
- #define ECNOTIFYMASTER_H
- #include <list>
- #include <map>
- #include <mutex>
- #include <pthread.h>
- #include <kopano/zcdefs.h>
- #include "ECSessionGroupManager.h"
- #include <kopano/ECUnknown.h>
- #include <kopano/kcodes.h>
- class ECNotifyClient;
- class ECNotifyMaster;
- class WSTransport;
- struct notification;
- typedef std::list<notification*> NOTIFYLIST;
- typedef HRESULT(ECNotifyClient::*NOTIFYCALLBACK)(ULONG,const NOTIFYLIST &);
- class ECNotifySink _kc_final {
- public:
- ECNotifySink(ECNotifyClient *lpClient, NOTIFYCALLBACK fnCallback);
- HRESULT Notify(ULONG ulConnection, const NOTIFYLIST &lNotifications) const;
- bool IsClient(const ECNotifyClient *) const;
- private:
- ECNotifyClient *m_lpClient;
- NOTIFYCALLBACK m_fnCallback;
- };
- typedef std::list<ECNotifyClient*> NOTIFYCLIENTLIST;
- typedef std::map<ULONG, ECNotifySink> NOTIFYCONNECTIONCLIENTMAP;
- typedef std::map<ULONG, NOTIFYLIST> NOTIFYCONNECTIONMAP;
- class ECNotifyMaster _kc_final : public ECUnknown {
- protected:
- ECNotifyMaster(SessionGroupData *lpData);
- virtual ~ECNotifyMaster(void);
- public:
- static HRESULT Create(SessionGroupData *lpData, ECNotifyMaster **lppMaster);
- virtual HRESULT ConnectToSession();
- virtual HRESULT AddSession(ECNotifyClient* lpClient);
- virtual HRESULT ReleaseSession(ECNotifyClient* lpClient);
- virtual HRESULT ReserveConnection(ULONG *lpulConnection);
- virtual HRESULT ClaimConnection(ECNotifyClient* lpClient, NOTIFYCALLBACK fnCallback, ULONG ulConnection);
- virtual HRESULT DropConnection(ULONG ulConnection);
- private:
-
- virtual HRESULT StartNotifyWatch();
- virtual HRESULT StopNotifyWatch();
- static void* NotifyWatch(void *pTmpNotifyClient);
-
- NOTIFYCLIENTLIST m_listNotifyClients;
-
- NOTIFYCONNECTIONCLIENTMAP m_mapConnections;
-
- SessionGroupData *m_lpSessionGroupData;
- WSTransport *m_lpTransport = nullptr;
- ULONG m_ulConnection = 0;
-
- std::recursive_mutex m_hMutex;
- pthread_t m_hThread;
- BOOL m_bThreadRunning = false;
- BOOL m_bThreadExit = false;
- };
- #endif
|