PageRenderTime 27ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1#ifndef		___DATA_HOST_IMP___
 2#define		___DATA_HOST_IMP___
 3
 4
 5#include "DataSessionMgr.h"
 6
 7//
 8//
 9//
10//
11class DataHost
12{
13public:
14	enum
15	{
16		num_working_thread	=	4,
17		num_session_mgrs	=	2,
18	};
19
20
21	DataHost();
22	virtual ~DataHost();
23
24	//
25	//	start & stop hosting
26	//
27	virtual bool start();
28	virtual bool stop();
29	virtual bool wait();
30
31	//
32	//	session recycle & reuse
33	//
34	virtual bool	createSession(DataSession*& pSes);
35	virtual	bool	releaseSession(DataSession*  pSes);
36
37	//
38	//	session start & end
39	//
40	virtual void onSessionStart(DataSession* pSes, const boost::system::error_code& error);
41	virtual void onSessionEnd(DataSession* pSes);
42protected:
43
44	void post_accept();
45
46protected:
47	boost::asio::io_service			m_theIoSvc;
48	boost::thread					m_theThreads[num_working_thread];
49	boost::asio::io_service::work	m_theEmptyWork;
50
51	boost::asio::ip::tcp::endpoint	m_theEndPoint;
52	boost::asio::ip::tcp::acceptor	m_theAcceptor;
53
54	DataSessionMgr*					m_theSesMgrs[num_session_mgrs];
55};
56
57#endif