summaryrefslogtreecommitdiff
path: root/src/network/network_server.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-15 21:56:06 +0000
committerrubidium <rubidium@openttd.org>2010-10-15 21:56:06 +0000
commit234bee0858b3c135f0827be63e904b8edacdee90 (patch)
tree0de110f2ffd193c3461ad837700d43dbb7c7e091 /src/network/network_server.h
parentc9cbab14ea4ad07354524dd1a7e7df4126722ba1 (diff)
downloadopenttd-234bee0858b3c135f0827be63e904b8edacdee90.tar.xz
(svn r20938) -Codechange: make the code for listening on a socket (more) reusable
Diffstat (limited to 'src/network/network_server.h')
-rw-r--r--src/network/network_server.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/network/network_server.h b/src/network/network_server.h
index 691411519..c5bc049f1 100644
--- a/src/network/network_server.h
+++ b/src/network/network_server.h
@@ -15,6 +15,7 @@
#ifdef ENABLE_NETWORK
#include "network_internal.h"
+#include "core/tcp_listen.h"
class ServerNetworkGameSocketHandler;
typedef ServerNetworkGameSocketHandler NetworkClientSocket;
@@ -22,7 +23,7 @@ typedef Pool<NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS> NetworkClien
extern NetworkClientSocketPool _networkclientsocket_pool;
/** Class for handling the server side of the game connection. */
-class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler {
+class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler, public TCPListenHandler<ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED> {
protected:
DECLARE_GAME_RECEIVE_COMMAND(PACKET_CLIENT_JOIN);
DECLARE_GAME_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO);
@@ -76,6 +77,19 @@ public:
NetworkRecvStatus SendCommand(const CommandPacket *cp);
NetworkRecvStatus SendCompanyUpdate();
NetworkRecvStatus SendConfigUpdate();
+
+ static void Send();
+ static void AcceptConnection(SOCKET s, const NetworkAddress &address);
+ static bool AllowConnection();
+
+ /**
+ * Get the name used by the listener.
+ * @return the name to show in debug logs and the like.
+ */
+ static const char *GetName()
+ {
+ return "server";
+ }
};
void NetworkServer_Tick(bool send_frame);