diff options
Diffstat (limited to 'src/Core/ConnectionManager.h')
-rw-r--r-- | src/Core/ConnectionManager.h | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h index 4623ab6..75395ad 100644 --- a/src/Core/ConnectionManager.h +++ b/src/Core/ConnectionManager.h @@ -36,7 +36,6 @@ namespace Mad { namespace Net { class Listener; -class Connection; class ServerConnection; class Packet; } @@ -45,6 +44,47 @@ namespace Core { class ConnectionManager : public Common::Configurable, public Common::Initializable { private: + class Connection : public Common::Connection { + public: + enum ConnectionType { + DAEMON, CLIENT + }; + + private: + Net::ServerConnection *connection; + ConnectionType type; + Common::HostInfo *hostInfo; + + protected: + virtual bool send(const Net::Packet &packet); + + public: + Connection(Net::ServerConnection *connection0, ConnectionType type0); + virtual ~Connection(); + + bool isConnected() const; + + virtual bool disconnect(); + virtual void* getCertificate(size_t *size) const; + virtual void* getPeerCertificate(size_t *size) const; + + ConnectionType getConnectionType() const { + return type; + } + + Common::HostInfo *getHostInfo() const { + return hostInfo; + } + + bool isIdentified() const { + return hostInfo; + } + + void identify(Common::HostInfo *info) { + hostInfo = info; + } + }; + static ConnectionManager connectionManager; std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; @@ -52,19 +92,15 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa std::vector<Net::IPAddress> listenerAddresses; std::list<Net::Listener*> listeners; - std::list<Net::ServerConnection*> daemonConnections; - std::list<Net::ServerConnection*> clientConnections; + std::list<Connection*> connections; std::map<std::string,Common::HostInfo> daemonInfo; - std::map<std::string,Net::ServerConnection*> identifiedDaemonConnections; // Prevent shallow copy ConnectionManager(const ConnectionManager &o); ConnectionManager& operator=(const ConnectionManager &o); - void handleConnections(std::list<Net::ServerConnection*> &connections); - - void updateState(const std::string &name, Common::HostInfo::State state); + void updateState(Common::HostInfo *hostInfo, Common::HostInfo::State state); ConnectionManager() {} @@ -82,10 +118,10 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa void run(); - Net::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&); - std::string getDaemonName(const Net::Connection *con) const throw (Common::Exception&); + Common::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&); + std::string getDaemonName(const Common::Connection *con) const throw (Common::Exception&); - void identifyDaemonConnection(Net::Connection *connection, const std::string &name) throw (Common::Exception&); + void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Common::Exception&); std::vector<Common::HostInfo> getDaemonList() const; }; |