PageRenderTime 35ms CodeModel.GetById 19ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/TGame/TClient/Service/ServiceImpNW.h

http://awoe.googlecode.com/
C++ Header | 64 lines | 34 code | 14 blank | 16 comment | 0 complexity | da3d1dfe57f87d9da201e97600c35e8a MD5 | raw file
 1#ifndef	___SERVICE_IMP_NETWORK___
 2#define	___SERVICE_IMP_NETWORK___
 3
 4
 5#include "Service/ServiceImp.h"
 6#include "Entry/LibExportCli.h"
 7#include "Service/Session.h"
 8#include "Message/MsgBuilderIf.h"
 9
10//
11//	Network Service for client
12//
13//
14class TCLI_API ServiceImpNW : public ServiceImp, public Session
15{
16public:
17
18	ServiceImpNW();
19	virtual ~ServiceImpNW();
20
21	//
22	//	initialize service
23	//
24	virtual void init(ServiceData& data);
25
26	//
27	//	session start & end
28	//
29	virtual void onSessionStart(const boost::system::error_code& error,  boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
30	virtual void onSessionEnd();
31protected:
32	virtual void onStart();
33	virtual void onStop();
34	//
35	//	callbacks
36	//
37	virtual void onTimer();
38	virtual void onDispatchMsg(IMsg* pMsg);
39
40	//
41	//	data on connections
42	//
43	void onInput(const boost::system::error_code& error, size_t bytes_transferred, MsgBuffer* buffer );
44	void onOutput(const boost::system::error_code& error, size_t bytes_transferred, MsgBuffer* buffer );
45protected:
46	void autoReconnect();
47
48	boost::asio::io_service::work	m_theEmptyWork;
49	boost::asio::ip::tcp::resolver	m_theResolver;
50	boost::asio::ip::tcp::endpoint	m_theEndPoint;
51
52
53	Service*	m_wpSvcLgc;
54
55	MsgBufferFactory	m_theMsgBuffFact;
56	IMsgBuilder*		m_pMsgBuilder;
57
58	string		m_strSvrIP;
59	string		m_strSvrPort;
60
61	bool		m_bConnected;
62};
63
64#endif