summaryrefslogtreecommitdiffstats
path: root/src/Daemon/Requests
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-09-17 05:33:01 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-09-17 05:33:01 +0200
commit039c218a7b1f2eae4f8e8305bc8e8bf70a67beab (patch)
tree362a59253abd77b5e41800d73a7c5dacf18617f7 /src/Daemon/Requests
parenta0cffb5475d35f0a19b95af2ce56bf6c90c82256 (diff)
downloadmad-039c218a7b1f2eae4f8e8305bc8e8bf70a67beab.tar
mad-039c218a7b1f2eae4f8e8305bc8e8bf70a67beab.zip
Interface der Request-Klassen verbessert; muss noch vereinfacht werden
Diffstat (limited to 'src/Daemon/Requests')
-rw-r--r--src/Daemon/Requests/IdentifyRequest.cpp26
-rw-r--r--src/Daemon/Requests/IdentifyRequest.h13
2 files changed, 13 insertions, 26 deletions
diff --git a/src/Daemon/Requests/IdentifyRequest.cpp b/src/Daemon/Requests/IdentifyRequest.cpp
index de3e359..e8b6082 100644
--- a/src/Daemon/Requests/IdentifyRequest.cpp
+++ b/src/Daemon/Requests/IdentifyRequest.cpp
@@ -18,35 +18,23 @@
*/
#include "IdentifyRequest.h"
-#include <Common/RequestManager.h>
-#include <Net/Packet.h>
+#include <Net/Connection.h>
namespace Mad {
namespace Daemon {
namespace Requests {
-bool IdentifyRequest::send(Net::Connection *connection, const std::string &hostname0) {
- IdentifyRequest *request = new IdentifyRequest(hostname0);
-
- if(Common::RequestManager::getRequestManager()->sendRequest(connection, request))
- return true;
-
- delete request;
- return false;
-}
-
-bool IdentifyRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(!connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length())))
- return false;
-
- return true;
+void IdentifyRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length()));
}
void IdentifyRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(packet.getType() != Net::Packet::OK)
+ if(packet.getType() != Net::Packet::OK) {
+ finishWithError(Common::Exception(Common::Exception::UNEXPECTED_PACKET));
return; // TODO Logging
+ }
- signalFinished().emit();
+ finish();
}
}
diff --git a/src/Daemon/Requests/IdentifyRequest.h b/src/Daemon/Requests/IdentifyRequest.h
index faec315..c728461 100644
--- a/src/Daemon/Requests/IdentifyRequest.h
+++ b/src/Daemon/Requests/IdentifyRequest.h
@@ -27,17 +27,16 @@ namespace Mad {
namespace Daemon {
namespace Requests {
-class IdentifyRequest : public Common::Request {
+class IdentifyRequest : public Common::Request<> {
private:
- IdentifyRequest(const std::string &hostname0) : hostname(hostname0) {}
-
std::string hostname;
- public:
- static bool send(Net::Connection *connection, const std::string &hostname0);
-
- virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ protected:
+ virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
virtual void handlePacket(Net::Connection*, const Net::Packet &packet);
+
+ public:
+ IdentifyRequest(const std::string &hostname0, slot_type slot) : Common::Request<>(slot), hostname(hostname0) {}
};
}