From 68f4dfa0e2996211a9439809df07e36614618a63 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 20 Mar 2008 03:21:59 +0000 Subject: This is a preliminary test of my new server simplification subclass, don't use it yet, the name will change. I really, really, really want the name to change. --- src/multiserver.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/multiserver.h (limited to 'src/multiserver.h') diff --git a/src/multiserver.h b/src/multiserver.h new file mode 100644 index 0000000..cf71203 --- /dev/null +++ b/src/multiserver.h @@ -0,0 +1,46 @@ +#ifndef BU_MULTI_SERVER_H +#define BU_MULTI_SERVER_H + +#include "bu/server.h" +#include "bu/hash.h" + +namespace Bu +{ + class Protocol; + class Client; + + template + Protocol *genProtocol() + { + return new T; + } + + class MultiServer : protected Server + { + public: + MultiServer(); + virtual ~MultiServer(); + + void addProtocol( Protocol *(*proc)(), int iPort, int nPoolSize=40 ); + void addProtocol( Protocol *(*proc)(), const FString &sAddr, int iPort, + int nPoolSize=40 ); + + void scan() + { + Server::scan(); + } + + void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ) + { + Server::setTimeout( nTimeoutSec, nTimeoutUSec ); + } + + virtual void onNewConnection( Client *pClient, int nPort ); + virtual void onClosedConnection( Client *pClient ); + + private: + Bu::Hash hProtos; + }; +} + +#endif -- cgit v1.2.3