summaryrefslogtreecommitdiffstats
path: root/src/Core/Requests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Requests')
-rw-r--r--src/Core/Requests/DaemonStatusRequest.cpp25
-rw-r--r--src/Core/Requests/DaemonStatusRequest.h17
2 files changed, 9 insertions, 33 deletions
diff --git a/src/Core/Requests/DaemonStatusRequest.cpp b/src/Core/Requests/DaemonStatusRequest.cpp
index 86ef3c6..1741731 100644
--- a/src/Core/Requests/DaemonStatusRequest.cpp
+++ b/src/Core/Requests/DaemonStatusRequest.cpp
@@ -25,34 +25,17 @@ namespace Mad {
namespace Core {
namespace Requests {
-bool DaemonStatusRequest::send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback) {
- DaemonStatusRequest *request = new DaemonStatusRequest();
-
- request->finished.connect(callback);
-
- if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request))
- return true;
-
- delete request;
- return false;
-}
-
-bool DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(!connection->send(Net::Packet(Net::Packet::STATUS, requestId)))
- return false;
-
- return true;
+void DaemonStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ connection->send(Net::Packet(Net::Packet::STATUS, requestId));
}
void DaemonStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
if(packet.getType() != Net::Packet::OK) {
- signalFinished().emit();
+ finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
- finished(Net::Packets::HostStatusPacket(packet));
-
- signalFinished().emit();
+ finish(Net::Packets::HostStatusPacket(packet));
}
}
diff --git a/src/Core/Requests/DaemonStatusRequest.h b/src/Core/Requests/DaemonStatusRequest.h
index ce6e4f7..baeb847 100644
--- a/src/Core/Requests/DaemonStatusRequest.h
+++ b/src/Core/Requests/DaemonStatusRequest.h
@@ -22,9 +22,6 @@
#include <Common/Request.h>
-#include <string>
-#include <sigc++/signal.h>
-
namespace Mad {
namespace Net {
@@ -36,17 +33,13 @@ class HostStatusPacket;
namespace Core {
namespace Requests {
-class DaemonStatusRequest : public Common::Request {
- private:
- sigc::signal<void,const Net::Packets::HostStatusPacket&> finished;
-
- DaemonStatusRequest() {}
+class DaemonStatusRequest : public Common::Request<Net::Packets::HostStatusPacket> {
+ protected:
+ virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
public:
- static bool send(Net::Connection *connection, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback);
-
- virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
- virtual void handlePacket(Net::Connection*, const Net::Packet &packet);
+ DaemonStatusRequest(slot_type slot) : Common::Request<Net::Packets::HostStatusPacket>(slot) {}
};
}