diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-17 05:33:01 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-17 05:33:01 +0200 |
commit | 039c218a7b1f2eae4f8e8305bc8e8bf70a67beab (patch) | |
tree | 362a59253abd77b5e41800d73a7c5dacf18617f7 /src/Core/Requests | |
parent | a0cffb5475d35f0a19b95af2ce56bf6c90c82256 (diff) | |
download | mad-039c218a7b1f2eae4f8e8305bc8e8bf70a67beab.tar mad-039c218a7b1f2eae4f8e8305bc8e8bf70a67beab.zip |
Interface der Request-Klassen verbessert; muss noch vereinfacht werden
Diffstat (limited to 'src/Core/Requests')
-rw-r--r-- | src/Core/Requests/DaemonStatusRequest.cpp | 25 | ||||
-rw-r--r-- | src/Core/Requests/DaemonStatusRequest.h | 17 |
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) {} }; } |