summaryrefslogtreecommitdiffstats
path: root/src/Client/Requests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client/Requests')
-rw-r--r--src/Client/Requests/DaemonStatusRequest.cpp16
-rw-r--r--src/Client/Requests/DaemonStatusRequest.h9
2 files changed, 12 insertions, 13 deletions
diff --git a/src/Client/Requests/DaemonStatusRequest.cpp b/src/Client/Requests/DaemonStatusRequest.cpp
index 94407b4..2d83b8b 100644
--- a/src/Client/Requests/DaemonStatusRequest.cpp
+++ b/src/Client/Requests/DaemonStatusRequest.cpp
@@ -26,20 +26,20 @@ namespace Client {
namespace Requests {
void DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- connection->send(Net::Packet(Net::Packet::DAEMON_STATUS, requestId, daemon.c_str(), daemon.length()));
+ Common::XmlPacket packet;
+ packet.setType("GetDaemonStatus");
+ packet.add("daemonName", daemon);
+
+ connection->send(packet.encode(requestId));
}
-void DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(packet.getType() == Net::Packet::ERROR) {
- finishWithError(Net::Packets::ErrorPacket(packet).getException());
- return;
- }
- else if(packet.getType() != Net::Packet::OK) {
+void DaemonStatusRequest::handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet) {
+ if(packet.getType() != "OK") {
finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
- finish(Net::Packets::HostStatusPacket(packet));
+ finish(packet);
}
}
diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h
index 3190ca1..b0982e6 100644
--- a/src/Client/Requests/DaemonStatusRequest.h
+++ b/src/Client/Requests/DaemonStatusRequest.h
@@ -20,8 +20,7 @@
#ifndef MAD_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_
#define MAD_CLIENT_REQUESTS_DAEMONSTATUSREQUEST_H_
-#include <Common/Request.h>
-#include <Net/Packets/HostStatusPacket.h>
+#include <Common/XmlRequest.h>
#include <string>
@@ -29,16 +28,16 @@ namespace Mad {
namespace Client {
namespace Requests {
-class DaemonStatusRequest : public Common::Request<Net::Packets::HostStatusPacket> {
+class DaemonStatusRequest : public Common::XmlRequest {
private:
std::string daemon;
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:
- DaemonStatusRequest(const std::string &daemon0, slot_type slot) : Common::Request<Net::Packets::HostStatusPacket>(slot), daemon(daemon0) {}
+ DaemonStatusRequest(const std::string &daemon0, slot_type slot) : Common::XmlRequest(slot), daemon(daemon0) {}
};
}