From 715d0c3952a3a1d59b64074e472d0a9a3b414351 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 14 Feb 2008 18:04:25 +0000 Subject: dedicated server accepts incoming connections --- src/core/netclient.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/core/netclient.h (limited to 'src/core/netclient.h') diff --git a/src/core/netclient.h b/src/core/netclient.h new file mode 100644 index 0000000..dcffb3c --- /dev/null +++ b/src/core/netclient.h @@ -0,0 +1,57 @@ +/* + core/netclient.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_CORE_NETCLIENT_H__ +#define __INCLUDED_CORE_NETCLIENT_H__ + +#include +#include +#include + +#include "net/tcpclient.h" +#include "core/player.h" + +namespace core +{ + +/// queues incoming client messages +class NetClient : public net::TCPClient +{ +public: + NetClient(int clientfd, std::string host, int port); + ~NetClient(); + + /// the remote hostname the client is connected to + std::string host() const; + + /// the remote port the client is connected to + int port() const; + + /// the player info associated with this client + Player & player(); + + /// return true if there are incoming messages + bool has_messages() const; + + /// receive an incoming message + void retreive(std::string & message); + + /// receive incoming data and store messages + void receive(); + +private: + std::string client_host; + int client_port; + Player client_player; + + std::string messageblock; + std::deque recvq; +}; + +} + +#endif // __INCLUDED_CORE_NETCLIENT_H__ + -- cgit v1.2.3