#include <dpl/raw-buffer.h>
#include <ckm/ckm-type.h>
#include <credentials.h>
+#include <service-messages.h>
extern "C" {
struct msghdr;
virtual void SetSocketManager(GenericSocketManager *manager) {
m_serviceManager = manager;
}
+ virtual void SetCommManager(CommMgr *manager) {
+ m_commMgr = manager;
+ }
virtual ServiceDescriptionVector GetServiceDescription() = 0;
virtual void Event(const AcceptEvent &event) = 0;
virtual void Start() = 0;
virtual void Stop() = 0;
- GenericSocketService() : m_serviceManager(NULL) {}
+ GenericSocketService() : m_serviceManager(NULL), m_commMgr(NULL) {}
virtual ~GenericSocketService(){}
protected:
GenericSocketManager *m_serviceManager;
+ CommMgr *m_commMgr;
};
struct GenericSocketManager {
void Start() {}
void Stop() {}
- void Event(const AcceptEvent &event) { (void)event; }
- void Event(const WriteEvent &event) { (void)event; }
- void Event(const ReadEvent &event) { (void)event; }
- void Event(const CloseEvent &event) { (void)event; }
+ void Event(const AcceptEvent &) {}
+ void Event(const WriteEvent &) {}
+ void Event(const ReadEvent &) {}
+ void Event(const CloseEvent &) {}
};
struct SignalService : public GenericSocketService {
void Start() {}
void Stop() {}
- void Event(const AcceptEvent &event) { (void)event; } // not supported
- void Event(const WriteEvent &event) { (void)event; } // not supported
- void Event(const CloseEvent &event) { (void)event; } // not supported
+ void Event(const AcceptEvent &) {} // not supported
+ void Event(const WriteEvent &) {} // not supported
+ void Event(const CloseEvent &) {} // not supported
void Event(const ReadEvent &event) {
LogDebug("Get signal information");
void SocketManager::RegisterSocketService(GenericSocketService *service) {
service->SetSocketManager(this);
+ service->SetCommManager(&m_commMgr);
auto serviceVector = service->GetServiceDescription();
Try {
for (auto iter = serviceVector.begin(); iter != serviceVector.end(); ++iter)
protected:
virtual bool ProcessOne(const ConnectionID &conn,
ConnectionInfo &info) = 0;
-private:
+
template <typename E>
void ThreadEvent(const E& event) {
CreateEvent([this, event]() { this->Handle(event); });
}
+private:
void Handle(const AcceptEvent &event);
void Handle(const WriteEvent &event);