/TGame/TServerMS/Service/ServiceImpHost.h
http://awoe.googlecode.com/ · C Header · 82 lines · 43 code · 17 blank · 22 comment · 0 complexity · 411d912c1af790cc87550423ac09c12e MD5 · raw file
- #ifndef ___DATA_HOST_IMP___
- #define ___DATA_HOST_IMP___
-
- #include "Service/ServiceImp.h"
- #include "ServiceDataSMS.h"
- #include "Service/Session.h"
- #include "Message/MsgBuilderIf.h"
-
- //
- // Network Service
- //
- //
- class ServiceImpHost : public ServiceImp
- {
- public:
- enum
- {
- num_working_thread = 4,
- num_session_mgrs = 2,
- };
-
-
- ServiceImpHost();
- virtual ~ServiceImpHost();
-
- virtual void init(ServiceData& data);
-
- //
- // session recycle & reuse
- //
- virtual bool createSession(Session*& pSes);
- virtual bool releaseSession(Session* pSes);
-
- //
- // get session by session/entity id
- //
- Session* getSession(int sid);
- void rmvSession(int sid);
-
- //
- // session start & end
- //
- virtual void onSessionStart(Session* pSes, const boost::system::error_code& error);
- virtual void onSessionEnd(Session* pSes);
- protected:
- virtual void onStart();
- virtual void onStop();
-
- //
- // callbacks
- //
- virtual void onTimer();
- virtual void onDispatchMsg(IMsg* pMsg);
- //
- // handle control message
- //
- virtual void onControlMsg(IMsg* pMsg);
-
- void post_accept();
- protected:
-
- boost::asio::io_service::work m_theEmptyWork;
- boost::asio::ip::tcp::endpoint m_theEndPoint;
- boost::asio::ip::tcp::acceptor m_theAcceptor;
-
- typedef stdext::hash_map<int, Session*> SessionMap;
- SessionMap m_mapSID2Session;
- int m_nCurrentSessionID;
-
- Service* m_wpSvcLgc;
-
- MsgBufferFactory m_theMsgBuffFact;
-
- IMsgBuilder* m_pMsgBuilder;
-
- //
- // configurations from properties file
- //
- short m_nPort;
- };
-
- #endif