/* * Copyright (C) 2007-2023 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; class ServerSocket; template Protocol *genProtocol() { return new T; } class MultiServer : protected Server { public: MultiServer(); virtual ~MultiServer(); void addProtocol( Protocol *(*proc)(), ServerSocket *pServer ); void scan() { Server::scan(); } void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ) { Server::setTimeout( nTimeoutSec, nTimeoutUSec ); } virtual void onNewConnection( const Bu::ServerSocket *pSrv, Client *pClient, Bu::Socket *pSocket ); virtual void onClosedConnection( Client *pClient ); void shutdown(); void tick(); private: Bu::Hash hProtos; }; } #endif