diff options
Diffstat (limited to 'src/Common/Request/IdentifyRequest.h')
-rw-r--r-- | src/Common/Request/IdentifyRequest.h | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/src/Common/Request/IdentifyRequest.h b/src/Common/Request/IdentifyRequest.h index 2637e47..276da23 100644 --- a/src/Common/Request/IdentifyRequest.h +++ b/src/Common/Request/IdentifyRequest.h @@ -21,55 +21,26 @@ #define MAD_COMMON_REQUEST_IDENTIFYREQUEST_H_ #include "Request.h" -#include "../RequestManager.h" -#include <Net/Connection.h> -#include <Net/Packet.h> #include <string> -#include <iostream> - namespace Mad { namespace Common { + +class RequestManager; + namespace Request { -class IdentifyRequest: public Request { +class IdentifyRequest : public Request { private: IdentifyRequest(const std::string &hostname0) : hostname(hostname0) {} std::string hostname; public: - static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &hostname0) { - IdentifyRequest *request = new IdentifyRequest(hostname0); - - if(requestManager.sendRequest(connection, request)) - return true; - - delete request; - return false; - } - - virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) { - if(isSent()) - return false; - - if(!connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length()))) - return false; - - setSent(); - return true; - } - - virtual bool handlePacket(Net::Connection*, const Net::Packet &packet) { - if(isFinished()) - return false; - - if(packet.getType() != Net::Packet::OK) - return false; // TODO Logging + static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &hostname0); - setFinished(); - return true; - } + virtual bool sendRequest(Net::Connection *connection, uint16_t requestId); + virtual bool handlePacket(Net::Connection*, const Net::Packet &packet); }; } |