diff options
Diffstat (limited to 'src/Server/ConnectionManager.cpp')
-rw-r--r-- | src/Server/ConnectionManager.cpp | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index f568f74..a15a516 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -18,16 +18,13 @@ */ #include "ConnectionManager.h" -#include <Common/ConfigEntry.h> -#include <Common/ConfigManager.h> -#include <Common/Logger.h> +#include <Core/ConfigEntry.h> +#include <Core/ConfigManager.h> +#include <Core/Logger.h> #include <Common/RequestHandlers/FSInfoRequestHandler.h> #include <Common/RequestHandlers/StatusRequestHandler.h> #include "Requests/DaemonStateUpdateRequest.h" -//#include "RequestHandlers/DaemonCommandRequestHandler.h" -//#include "RequestHandlers/DaemonFSInfoRequestHandler.h" #include "RequestHandlers/DaemonListRequestHandler.h" -//#include "RequestHandlers/DaemonStatusRequestHandler.h" //#include "RequestHandlers/GSSAPIAuthRequestHandler.h" #include "RequestHandlers/IdentifyRequestHandler.h" #include "RequestHandlers/LogRequestHandler.h" @@ -89,7 +86,7 @@ void ConnectionManager::updateState(Common::HostInfo *hostInfo, Common::HostInfo } } -bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool handled) { +bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) { if(handled) return false; @@ -97,7 +94,7 @@ bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool try { listenerAddresses.push_back(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(entry[0][0]), 6666)); } - catch(Net::Exception &e) { + catch(Core::Exception &e) { // TODO Log error } @@ -148,7 +145,7 @@ void ConnectionManager::configFinished() { listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1)); listeners.push_back(listener); } - catch(Net::Exception &e) { + catch(Core::Exception &e) { // TODO Log error } } @@ -159,7 +156,7 @@ void ConnectionManager::configFinished() { listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1)); listeners.push_back(listener); } - catch(Net::Exception &e) { + catch(Core::Exception &e) { // TODO Log error } } @@ -220,14 +217,14 @@ void ConnectionManager::doDeinit() { Common::RequestManager::get()->unregisterPacketType("Log"); } -boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const std::string &name) const throw (Net::Exception&) { +boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const std::string &name) const throw (Core::Exception&) { const Common::HostInfo *hostInfo; try { hostInfo = &daemonInfo.at(name); } catch(std::out_of_range&) { - throw Net::Exception(Net::Exception::UNKNOWN_DAEMON); + throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); } if(hostInfo->getState() != Common::HostInfo::INACTIVE) { @@ -238,56 +235,56 @@ boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(con } } - throw Net::Exception(Net::Exception::NOT_AVAILABLE); + throw Core::Exception(Core::Exception::NOT_AVAILABLE); } -std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Net::Exception&) { +std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Core::Exception&) { const ServerConnection *connection = dynamic_cast<const ServerConnection*>(con); if(connection && connection->getConnectionType() == ServerConnection::DAEMON) return connection->getHostInfo()->getName(); - throw Net::Exception(Net::Exception::UNKNOWN_DAEMON); + throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); } -void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Net::Exception&) { +void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception&) { // TODO Logging ServerConnection *connection = dynamic_cast<ServerConnection*>(con); if(!connection) - throw Net::Exception(Net::Exception::INVALID_ACTION); + throw Core::Exception(Core::Exception::INVALID_ACTION); if(connection->isIdentified()) - throw Net::Exception(Net::Exception::ALREADY_IDENTIFIED); + throw Core::Exception(Core::Exception::ALREADY_IDENTIFIED); if(daemonInfo.count(name) == 0) - throw Net::Exception(Net::Exception::UNKNOWN_DAEMON); + throw Core::Exception(Core::Exception::UNKNOWN_DAEMON); Common::HostInfo *hostInfo = &daemonInfo[name]; if(hostInfo->getState() != Common::HostInfo::INACTIVE) { try { getDaemonConnection(name)->disconnect(); - Common::Logger::log(Common::Logger::WARNING, "Disconnecting old connection."); + Core::Logger::log(Core::Logger::WARNING, "Disconnecting old connection."); } - catch(Net::Exception&) {} + catch(Core::Exception&) {} } connection->identify(hostInfo); updateState(hostInfo, Common::HostInfo::RUNNING); - Common::Logger::logf("Identified as '%s'.", name.c_str()); + Core::Logger::logf("Identified as '%s'.", name.c_str()); } -void ConnectionManager::identifyClientConnection(Common::Connection *con) throw (Net::Exception&) { +void ConnectionManager::identifyClientConnection(Common::Connection *con) throw (Core::Exception&) { ServerConnection *connection = dynamic_cast<ServerConnection*>(con); if(!connection) - throw Net::Exception(Net::Exception::INVALID_ACTION); + throw Core::Exception(Core::Exception::INVALID_ACTION); if(connection->isIdentified()) - throw Net::Exception(Net::Exception::ALREADY_IDENTIFIED); + throw Core::Exception(Core::Exception::ALREADY_IDENTIFIED); connection->identify(); } |