diff options
Diffstat (limited to 'src/Client/Requests/DaemonCommandRequest.cpp')
-rw-r--r-- | src/Client/Requests/DaemonCommandRequest.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/Client/Requests/DaemonCommandRequest.cpp b/src/Client/Requests/DaemonCommandRequest.cpp index d27c3fb..6e82c60 100644 --- a/src/Client/Requests/DaemonCommandRequest.cpp +++ b/src/Client/Requests/DaemonCommandRequest.cpp @@ -18,28 +18,33 @@ */ #include "DaemonCommandRequest.h" +#include <Common/XmlPacket.h> #include <Net/Connection.h> -#include <Net/Packets/ErrorPacket.h> namespace Mad { namespace Client { namespace Requests { void DaemonCommandRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - connection->send(Net::Packet(reboot ? Net::Packet::DAEMON_COMMAND_REBOOT : Net::Packet::DAEMON_COMMAND_SHUTDOWN, requestId, daemon.c_str(), daemon.length())); + Common::XmlPacket packet; + packet.setType("DaemonCommand"); + packet.add("command", reboot ? "reboot" : "shutdown"); + packet.add("daemon", daemon); + + connection->send(packet.encode(requestId)); } -void DaemonCommandRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() == Net::Packet::ERROR) { - finishWithError(Net::Packets::ErrorPacket(packet).getException()); +void DaemonCommandRequest::handlePacket(Net::Connection*, uint16_t, const Common::XmlPacket &packet) { + if(packet.getType() == "Error") { + finishWithError(Common::Exception(packet["Where"], packet["ErrorCode"], packet["SubCode"], packet["SubSubCode"])); return; } - else if(packet.getType() != Net::Packet::OK) { + else if(packet.getType() != "OK") { finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET)); return; // TODO Logging } - finish(); + finish(packet); } } |