From 46c110f7a14e4b5d0e8bd27259f7744ae8a36382 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 28 Feb 2009 19:09:43 +0100 Subject: DaemonListRequest und DaemonStateUpdateRequest benutzen jetzt XML --- src/Core/Requests/DaemonStateUpdateRequest.cpp | 14 +++++++++----- src/Core/Requests/DaemonStateUpdateRequest.h | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/Core/Requests') diff --git a/src/Core/Requests/DaemonStateUpdateRequest.cpp b/src/Core/Requests/DaemonStateUpdateRequest.cpp index 00e0bdf..c00468e 100644 --- a/src/Core/Requests/DaemonStateUpdateRequest.cpp +++ b/src/Core/Requests/DaemonStateUpdateRequest.cpp @@ -19,23 +19,27 @@ #include "DaemonStateUpdateRequest.h" #include -#include namespace Mad { namespace Core { namespace Requests { void DaemonStateUpdateRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packets::HostStatePacket(Net::Packet::DAEMON_STATE_UPDATE, requestId, name, state)); + Common::XmlPacket packet; + + packet.setType("UpdateHostState"); + packet.add("name", name); + packet.add("state", state); + connection->send(packet.encode(requestId)); } -void DaemonStateUpdateRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { +void DaemonStateUpdateRequest::handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet) { + if(packet.getType() != "OK") { finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finish(); + finish(packet); } } diff --git a/src/Core/Requests/DaemonStateUpdateRequest.h b/src/Core/Requests/DaemonStateUpdateRequest.h index 9a1c8f0..84c23e8 100644 --- a/src/Core/Requests/DaemonStateUpdateRequest.h +++ b/src/Core/Requests/DaemonStateUpdateRequest.h @@ -20,24 +20,24 @@ #ifndef MAD_CORE_REQUESTS_DAEMONSTATEUPDATEREQUEST_H_ #define MAD_CORE_REQUESTS_DAEMONSTATEUPDATEREQUEST_H_ -#include +#include #include namespace Mad { namespace Core { namespace Requests { -class DaemonStateUpdateRequest : public Common::Request<> { +class DaemonStateUpdateRequest : public Common::XmlRequest { private: std::string name; Common::HostInfo::State state; protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - DaemonStateUpdateRequest(const std::string &name0, Common::HostInfo::State state0) : Common::Request<>(slot_type()), name(name0), state(state0) {} + DaemonStateUpdateRequest(const std::string &name0, Common::HostInfo::State state0) : Common::XmlRequest(slot_type()), name(name0), state(state0) {} }; } -- cgit v1.2.3