diff options
Diffstat (limited to 'src/Client')
-rw-r--r-- | src/Client/InformationManager.cpp | 21 | ||||
-rw-r--r-- | src/Client/InformationManager.h | 10 | ||||
-rw-r--r-- | src/Client/Requests/DaemonStatusRequest.cpp | 2 |
3 files changed, 10 insertions, 23 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp index 03a71c6..6bcdc8c 100644 --- a/src/Client/InformationManager.cpp +++ b/src/Client/InformationManager.cpp @@ -29,20 +29,7 @@ namespace Client { InformationManager InformationManager::informationManager; -void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) { - if(packet->getType() != "UpdateHostState") { - Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet."); - - Common::XmlPacket ret; - ret.setType("Error"); - ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); - - sendPacket(ret); - - signalFinished(); - return; - } - +void InformationManager::DaemonStateUpdateRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret) { // TODO Require authentication { @@ -55,11 +42,7 @@ void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(boost::sh Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host."); } - Common::XmlPacket ret; - ret.setType("OK"); - sendPacket(ret); - - signalFinished(); + ret->setType("OK"); } diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h index a7d2354..78b1f88 100644 --- a/src/Client/InformationManager.h +++ b/src/Client/InformationManager.h @@ -26,6 +26,7 @@ #include <Common/HostInfo.h> #include <Common/Initializable.h> #include <Common/Request.h> +#include <Common/RequestHandlers/SimpleRequestHandler.h> #include <boost/thread/condition_variable.hpp> #include <boost/thread/locks.hpp> @@ -36,9 +37,12 @@ namespace Client { class InformationManager : public Common::Initializable, private boost::noncopyable { private: - class DaemonStateUpdateRequestHandler : public Common::RequestHandler { - protected: - virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet); + class DaemonStateUpdateRequestHandler : public Common::RequestHandlers::SimpleRequestHandler { + private: + static void handleRequest(boost::shared_ptr<const Common::XmlPacket> packet, Common::XmlPacket *ret); + + public: + DaemonStateUpdateRequestHandler() : Common::RequestHandlers::SimpleRequestHandler("UpdateHostState", &DaemonStateUpdateRequestHandler::handleRequest) {} }; static InformationManager informationManager; diff --git a/src/Client/Requests/DaemonStatusRequest.cpp b/src/Client/Requests/DaemonStatusRequest.cpp index 9f0a9a0..ff1cda3 100644 --- a/src/Client/Requests/DaemonStatusRequest.cpp +++ b/src/Client/Requests/DaemonStatusRequest.cpp @@ -26,7 +26,7 @@ namespace Requests { void DaemonStatusRequest::sendRequest() { Common::XmlPacket packet; packet.setType("GetDaemonStatus"); - packet.add("daemonName", daemon); + packet.add("daemon", daemon); sendPacket(packet); } |