diff options
Diffstat (limited to 'src/Common/Request')
-rw-r--r-- | src/Common/Request/DisconnectRequest.h | 4 | ||||
-rw-r--r-- | src/Common/Request/IdentifyRequest.h (renamed from src/Common/Request/PingRequest.h) | 26 | ||||
-rw-r--r-- | src/Common/Request/Makefile.am | 2 | ||||
-rw-r--r-- | src/Common/Request/Makefile.in | 2 |
4 files changed, 18 insertions, 16 deletions
diff --git a/src/Common/Request/DisconnectRequest.h b/src/Common/Request/DisconnectRequest.h index 9023c13..77509a0 100644 --- a/src/Common/Request/DisconnectRequest.h +++ b/src/Common/Request/DisconnectRequest.h @@ -48,7 +48,7 @@ class DisconnectRequest: public Request { if(isSent()) return false; - if(!connection->send(Net::Packet(Net::Packet::TYPE_DISCONNECT_REQ, requestId))) + if(!connection->send(Net::Packet(Net::Packet::TYPE_DISCONNECT, requestId))) return false; setSent(); @@ -59,7 +59,7 @@ class DisconnectRequest: public Request { if(isFinished()) return false; - if(packet.getType() != Net::Packet::TYPE_DISCONNECT_REP) + if(packet.getType() != Net::Packet::TYPE_OK) return false; // TODO Logging connection->disconnect(); diff --git a/src/Common/Request/PingRequest.h b/src/Common/Request/IdentifyRequest.h index 92e3c1a..9df1548 100644 --- a/src/Common/Request/PingRequest.h +++ b/src/Common/Request/IdentifyRequest.h @@ -1,5 +1,5 @@ /* - * PingRequest.h + * IdentifyRequest.h * * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de> * @@ -17,13 +17,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MAD_COMMON_REQUEST_PINGREQUEST_H_ -#define MAD_COMMON_REQUEST_PINGREQUEST_H_ +#ifndef IDENTIFYREQUEST_H_ +#define IDENTIFYREQUEST_H_ #include "Request.h" #include "../RequestManager.h" #include <Net/Connection.h> #include <Net/Packet.h> +#include <string> #include <iostream> @@ -31,13 +32,15 @@ namespace Mad { namespace Common { namespace Request { -class PingRequest : public Request { +class IdentifyRequest: public Request { private: - PingRequest() {} + IdentifyRequest(const std::string &hostname0) : hostname(hostname0) {} + + std::string hostname; public: - static bool send(Net::Connection *connection, RequestManager &requestManager) { - Request *request = new PingRequest(); + static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &hostname0) { + Request *request = new IdentifyRequest(hostname0); if(requestManager.sendRequest(connection, request)) return true; @@ -50,7 +53,7 @@ class PingRequest : public Request { if(isSent()) return false; - if(!connection->send(Net::Packet(Net::Packet::TYPE_PING, requestId))) + if(!connection->send(Net::Packet(Net::Packet::TYPE_IDENTIFY_REQ, requestId, hostname.c_str(), hostname.length()))) return false; setSent(); @@ -61,11 +64,10 @@ class PingRequest : public Request { if(isFinished()) return false; - if(packet.getType() != Net::Packet::TYPE_PONG) + if(packet.getType() != Net::Packet::TYPE_IDENTIFY_REP) return false; // TODO Logging - std::cout << "Received ping reply." << std::endl; - std::cout << " Request ID: " << packet.getRequestId() << std::endl; + std::cout << "Identified as '" << hostname << "'." << std::endl; setFinished(); return true; @@ -76,4 +78,4 @@ class PingRequest : public Request { } } -#endif /* MAD_COMMON_REQUEST_PINGREQUEST_H_ */ +#endif /* IDENTIFYREQUEST_H_ */ diff --git a/src/Common/Request/Makefile.am b/src/Common/Request/Makefile.am index 17e47fe..a7de050 100644 --- a/src/Common/Request/Makefile.am +++ b/src/Common/Request/Makefile.am @@ -1 +1 @@ -noinst_HEADERS = DisconnectRequest.h PingRequest.h Request.h +noinst_HEADERS = DisconnectRequest.h IdentifyRequest.h Request.h diff --git a/src/Common/Request/Makefile.in b/src/Common/Request/Makefile.in index d96c0a7..9c48118 100644 --- a/src/Common/Request/Makefile.in +++ b/src/Common/Request/Makefile.in @@ -162,7 +162,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -noinst_HEADERS = DisconnectRequest.h PingRequest.h Request.h +noinst_HEADERS = DisconnectRequest.h IdentifyRequest.h Request.h all: all-am .SUFFIXES: |