1.引入头文件
#include "Comm.h"
2.派生自框架基类CProtocolCpMgr
class NetManager : public CProtocolCpMgr
3.实现基类的纯虚函数,按照C++11定义如下
virtual int Forward(CPacket &GessPacket, const unsigned long& ulKey) override;//异步数据流转接口
virtual int OnAccept(const unsigned long& ulKey, const string& sLocalIp, int nLocalPort, const string& sPeerIp, int nPeerPort) override;
virtual int OnConnect(const unsigned long& ulKey, const string& sLocalIp, int nLocalPort, const string& sPeerIp, int nPeerPort, int nFlag) override;
virtual int OnLogin(const unsigned long& ulKey, const string& sLocalIp, int nLocalPort, const string& sPeerIp, int nPeerPort, int nFlag) override;
virtual int OnClose(const unsigned long& ulKey, const string& sLocalIp, int nLocalPort, const string& sPeerIp, int nPeerPort) override;
4.定义网络通讯接口类对象
CConnectPointAsyn*m_pCpInterfaceYC;//通讯接口机广播Y接口
CConnectPointSync*m_pCpInterfaceB1C;//认证接口
CConnectPointSync*m_pCpInterfaceB2C;//交易接口
CConnectPointSync*m_pCpInterfaceB2CVip;//交易专用通道
CConnectPointSync*m_pCpInterfaceB3C;//查询接口
CConnectPointSync*m_pCpInterfaceB4C;//风控接口