• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ypdxcn
博客园    首页    新随笔    联系   管理    订阅  订阅

Framwork框架-网络客户端的使用

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; //风控接口

 

posted @ 2018-05-07 00:37  ypdxcn  阅读(218)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3