summaryrefslogtreecommitdiffstats
path: root/src/Client/Requests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Client/Requests')
-rw-r--r--src/Client/Requests/DaemonStatusRequest.cpp13
-rw-r--r--src/Client/Requests/DaemonStatusRequest.h8
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);