Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-02-14 18:04:25 +0000
committerStijn Buys <ingar@osirion.org>2008-02-14 18:04:25 +0000
commit715d0c3952a3a1d59b64074e472d0a9a3b414351 (patch)
treea5d0ddd0613caaf4f9fe01f9a3bd34e823651ad5 /src/core/netclient.h
parent83e8023c5e46635753a609329cf9805a3520001e (diff)
dedicated server accepts incoming connections
Diffstat (limited to 'src/core/netclient.h')
-rw-r--r--src/core/netclient.h57
1 files changed, 57 insertions, 0 deletions
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 <string>
+#include <deque>
+#include <map>
+
+#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<std::string> recvq;
+};
+
+}
+
+#endif // __INCLUDED_CORE_NETCLIENT_H__
+