/TGame/TServerGate/Network/DataHost.h
http://awoe.googlecode.com/ · C Header · 57 lines · 31 code · 13 blank · 13 comment · 0 complexity · b3a8f33627d2c99f419661c0c92e0a3c MD5 · raw file
- #ifndef ___DATA_HOST_IMP___
- #define ___DATA_HOST_IMP___
-
-
- #include "DataSessionMgr.h"
-
- //
- //
- //
- //
- class DataHost
- {
- public:
- enum
- {
- num_working_thread = 4,
- num_session_mgrs = 2,
- };
-
-
- DataHost();
- virtual ~DataHost();
-
- //
- // start & stop hosting
- //
- virtual bool start();
- virtual bool stop();
- virtual bool wait();
-
- //
- // session recycle & reuse
- //
- virtual bool createSession(DataSession*& pSes);
- virtual bool releaseSession(DataSession* pSes);
-
- //
- // session start & end
- //
- virtual void onSessionStart(DataSession* pSes, const boost::system::error_code& error);
- virtual void onSessionEnd(DataSession* pSes);
- protected:
-
- void post_accept();
-
- protected:
- boost::asio::io_service m_theIoSvc;
- boost::thread m_theThreads[num_working_thread];
- boost::asio::io_service::work m_theEmptyWork;
-
- boost::asio::ip::tcp::endpoint m_theEndPoint;
- boost::asio::ip::tcp::acceptor m_theAcceptor;
-
- DataSessionMgr* m_theSesMgrs[num_session_mgrs];
- };
-
- #endif