diff options
Diffstat (limited to 'src/Daemon/Requests')
-rw-r--r-- | src/Daemon/Requests/IdentifyRequest.cpp | 13 | ||||
-rw-r--r-- | src/Daemon/Requests/IdentifyRequest.h | 8 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/Daemon/Requests/IdentifyRequest.cpp b/src/Daemon/Requests/IdentifyRequest.cpp index e8b6082..6334f00 100644 --- a/src/Daemon/Requests/IdentifyRequest.cpp +++ b/src/Daemon/Requests/IdentifyRequest.cpp @@ -19,22 +19,27 @@ #include "IdentifyRequest.h" #include <Net/Connection.h> +#include <Common/XmlPacket.h> namespace Mad { namespace Daemon { namespace Requests { void IdentifyRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length())); + Common::XmlPacket packet; + packet.setType("Identify"); + packet.add("hostname", hostname); + + connection->send(packet.encode(requestId)); } -void IdentifyRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { +void IdentifyRequest::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/Daemon/Requests/IdentifyRequest.h b/src/Daemon/Requests/IdentifyRequest.h index c728461..c3ab821 100644 --- a/src/Daemon/Requests/IdentifyRequest.h +++ b/src/Daemon/Requests/IdentifyRequest.h @@ -20,23 +20,23 @@ #ifndef MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ #define MAD_DAEMON_REQUESTS_IDENTIFYREQUEST_H_ -#include <Common/Request.h> +#include <Common/XmlRequest.h> #include <string> namespace Mad { namespace Daemon { namespace Requests { -class IdentifyRequest : public Common::Request<> { +class IdentifyRequest : public Common::XmlRequest { private: std::string hostname; protected: virtual void sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection*, const Net::Packet &packet); + virtual void handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet); public: - IdentifyRequest(const std::string &hostname0, slot_type slot) : Common::Request<>(slot), hostname(hostname0) {} + IdentifyRequest(const std::string &hostname0, slot_type slot) : Common::XmlRequest(slot), hostname(hostname0) {} }; } |