From 469bbcf0701e1eb8a6670c23145b0da87357e178 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 25 Mar 2012 20:00:08 +0000 Subject: Code is all reorganized. We're about ready to release. I should write up a little explenation of the arrangement. --- src/stable/multiserver.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/stable/multiserver.h (limited to 'src/stable/multiserver.h') diff --git a/src/stable/multiserver.h b/src/stable/multiserver.h new file mode 100644 index 0000000..e3b3ec3 --- /dev/null +++ b/src/stable/multiserver.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2007-2011 Xagasoft, All rights reserved. + * + * This file is part of the libbu++ library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#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 String &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 ); + + void shutdown(); + + void tick(); + + private: + Bu::Hash hProtos; + }; +} + +#endif -- cgit v1.2.3