diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2008-03-20 03:21:59 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2008-03-20 03:21:59 +0000 |
| commit | 68f4dfa0e2996211a9439809df07e36614618a63 (patch) | |
| tree | 7e86ff3cdb8863629c77aa50b6b922678ce2cb4c /src/multiserver.h | |
| parent | 6c27b9b4024331558e6a719293f2b44a6ae77c28 (diff) | |
| download | libbu++-68f4dfa0e2996211a9439809df07e36614618a63.tar.gz libbu++-68f4dfa0e2996211a9439809df07e36614618a63.tar.bz2 libbu++-68f4dfa0e2996211a9439809df07e36614618a63.tar.xz libbu++-68f4dfa0e2996211a9439809df07e36614618a63.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | src/multiserver.h | 46 |
1 files changed, 46 insertions, 0 deletions
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 @@ | |||
| 1 | #ifndef BU_MULTI_SERVER_H | ||
| 2 | #define BU_MULTI_SERVER_H | ||
| 3 | |||
| 4 | #include "bu/server.h" | ||
| 5 | #include "bu/hash.h" | ||
| 6 | |||
| 7 | namespace Bu | ||
| 8 | { | ||
| 9 | class Protocol; | ||
| 10 | class Client; | ||
| 11 | |||
| 12 | template<class T> | ||
| 13 | Protocol *genProtocol() | ||
| 14 | { | ||
| 15 | return new T; | ||
| 16 | } | ||
| 17 | |||
| 18 | class MultiServer : protected Server | ||
| 19 | { | ||
| 20 | public: | ||
| 21 | MultiServer(); | ||
| 22 | virtual ~MultiServer(); | ||
| 23 | |||
| 24 | void addProtocol( Protocol *(*proc)(), int iPort, int nPoolSize=40 ); | ||
| 25 | void addProtocol( Protocol *(*proc)(), const FString &sAddr, int iPort, | ||
| 26 | int nPoolSize=40 ); | ||
| 27 | |||
| 28 | void scan() | ||
| 29 | { | ||
| 30 | Server::scan(); | ||
| 31 | } | ||
| 32 | |||
| 33 | void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ) | ||
| 34 | { | ||
| 35 | Server::setTimeout( nTimeoutSec, nTimeoutUSec ); | ||
| 36 | } | ||
| 37 | |||
| 38 | virtual void onNewConnection( Client *pClient, int nPort ); | ||
| 39 | virtual void onClosedConnection( Client *pClient ); | ||
| 40 | |||
| 41 | private: | ||
| 42 | Bu::Hash<int, Protocol *(*)()> hProtos; | ||
| 43 | }; | ||
| 44 | } | ||
| 45 | |||
| 46 | #endif | ||
