Framwork framework - the use of network clients

1. Introduce header files

#include "Comm.h"

2. Derived from the framework base class CProtocolCpMgr

class NetManager : public CProtocolCpMgr

3. Implement the pure virtual function of the base class, which is defined as follows according to 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. Define the network communication interface class object

CConnectPointAsyn* m_pCpInterfaceYC; //communication interface machine broadcast Y interface
CConnectPointSync* m_pCpInterfaceB1C; //authentication interface
CConnectPointSync* m_pCpInterfaceB2C; //transaction interface CConnectPointSync
* m_pCpInterfaceB2CVip ; /wind control interface

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325499513&siteId=291194637