diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-03-01 00:51:00 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-03-01 00:51:00 +0100 |
commit | 63907817cb057f497f03a28016d408885cbe41ea (patch) | |
tree | a9ad6b0b19bff7722b21375137ba6e53c8869c91 /src/Client/Requests/DaemonCommandRequest.cpp | |
parent | 46c110f7a14e4b5d0e8bd27259f7744ae8a36382 (diff) | |
download | mad-63907817cb057f497f03a28016d408885cbe41ea.tar mad-63907817cb057f497f03a28016d408885cbe41ea.zip |
Alle uebrigen Requests ausser GSSAPIAuthRequest in XmlRequests umgewandelt
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); } } |