diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-16 04:54:36 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-16 04:54:36 +0200 |
commit | d08a98b8304eb2c831907254095d6829fb98a95b (patch) | |
tree | 5ae7b3dfa427b3680ded829a8d5c12e8ed16ae3a /src/Client/Requests | |
parent | a37ee55e14db26ca273ddeca5b0ab0fb8c8de77c (diff) | |
download | mad-d08a98b8304eb2c831907254095d6829fb98a95b.tar mad-d08a98b8304eb2c831907254095d6829fb98a95b.zip |
Korrekte Reaktion auf Fehler in DaemonStatusRequest
Diffstat (limited to 'src/Client/Requests')
-rw-r--r-- | src/Client/Requests/DaemonStatusRequest.cpp | 13 | ||||
-rw-r--r-- | src/Client/Requests/DaemonStatusRequest.h | 8 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/Client/Requests/DaemonStatusRequest.cpp b/src/Client/Requests/DaemonStatusRequest.cpp index 7a7b47e..719ae5c 100644 --- a/src/Client/Requests/DaemonStatusRequest.cpp +++ b/src/Client/Requests/DaemonStatusRequest.cpp @@ -19,16 +19,20 @@ #include "DaemonStatusRequest.h" #include <Common/RequestManager.h> +#include <Net/Packets/ErrorPacket.h> #include <Net/Packets/HostStatusPacket.h> namespace Mad { namespace Client { namespace Requests { -bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback, const std::string &daemon0) { +bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback, + const sigc::slot<void,const Common::Exception&> &errorCallback, const std::string &daemon0) +{ DaemonStatusRequest *request = new DaemonStatusRequest(daemon0); request->finished.connect(callback); + request->error.connect(errorCallback); if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request)) return true; @@ -45,7 +49,12 @@ bool DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requ } void DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) { - if(packet.getType() != Net::Packet::OK) { + if(packet.getType() == Net::Packet::ERROR) { + error(Net::Packets::ErrorPacket(packet).getException()); + signalFinished().emit(); + return; + } + else if(packet.getType() != Net::Packet::OK) { signalFinished().emit(); return; // TODO Logging } diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h index 34d3a90..f5c130d 100644 --- a/src/Client/Requests/DaemonStatusRequest.h +++ b/src/Client/Requests/DaemonStatusRequest.h @@ -27,6 +27,10 @@ namespace Mad { +namespace Common { +class Exception; +} + namespace Net { namespace Packets { class HostStatusPacket; @@ -39,13 +43,15 @@ namespace Requests { class DaemonStatusRequest : public Common::Request { private: sigc::signal<void,const Net::Packets::HostStatusPacket&> finished; + sigc::signal<void,const Common::Exception&> error; std::string daemon; DaemonStatusRequest(const std::string &daemon0) : daemon(daemon0) {} public: - static bool send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback, const std::string &daemon0); + static bool send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback, + const sigc::slot<void,const Common::Exception&> &errorCallback, const std::string &daemon0); virtual bool sendRequest(Net::Connection *connection, uint16_t requestId); virtual void handlePacket(Net::Connection*, const Net::Packet &packet); |