/* * @Description: TCPClient * @Version: 1.0 * @Autor: lishengyin * @Date: 2021-09-13 17:30:20 * @LastEditors: lishengyin * @LastEditTime: 2021-10-15 15:46:34 */ #pragma once #include #include #include "Util/logger.h" #include "Network/TcpClient.h" #include "Util/NoticeCenter.h" #include "Notices.h" using namespace std; using namespace toolkit; // dataType #include "SendLogin.h" #include "NettyServerCommandEnum.h" #include "NettyServerResultMsg.h" #include "NettyClientResultMsg.h" #include "SendLogin.h" #include "NettyClientCommandEnum.h" #include "SendHeartBeat.h" namespace MIVA { class TCPClient: public TcpClient { private: /* data */ public: typedef std::shared_ptr Ptr; TCPClient():TcpClient() { DebugL; } ~TCPClient(){ DebugL; } protected: /** * @description: 连接成功时触发 * @param {SockException} &ex 连接info * @return {*} * @author: lishengyin */ virtual void onConnect(const SockException &ex) override; /** * @description: 接收数据时触发 * @param {Ptr} &pBuf 接受到的数据 * @return {*} * @author: lishengyin */ virtual void onRecv(const Buffer::Ptr &pBuf) override; /** * @description: 发送阻塞时触发 * @param {*} * @return {*} * @author: lishengyin */ virtual void onFlush() override; /** * @description: EOF时触发 * @param {SockException} &ex 错误信息 * @return {*} * @author: lishengyin */ virtual void onErr(const SockException &ex) override; /** * @description: 心跳 2S触发一次 * @param {*} * @return {*} * @author: lishengyin */ virtual void onManager() override; private: int _nTick = 0; std::string _IP; int32_t _port; }; } // namespace VIA