summaryrefslogtreecommitdiffstats
path: root/src/Daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/Daemon')
-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) {}
};
}