/* * @Description: TCPClient * @Version: 1.0 * @Autor: lishengyin * @Date: 2021-09-13 17:30:20 * @LastEditors: lishengyin * @LastEditTime: 2021-11-18 17:48:35 */ #pragma once #include <signal.h> #include <iostream> #include "Util/logger.h" #include "Network/TcpClient.h" #include "Util/NoticeCenter.h" #include "Notices.h" #include "md5.h" #include <time.h> #include <ctime> 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" #include "Util/logger.h" #include "Util/NoticeCenter.h" #include "Poller/EventPoller.h" #include "Player/PlayerProxy.h" #include "Rtmp/RtmpPusher.h" #include "Common/config.h" #include "Pusher/MediaPusher.h" #include "Extension/Frame.h" #include "Util/SqlPool.h" #include "Network/TcpClient.h" #include "Poller/Timer.h" namespace MIVA { class TCPClient: public TcpClient { public: std::string privateKey = "mwWAH2eUAAHodlRt"; std::string Account = "nettyUser2"; std::string pwd = "sunwin20211102"; public: typedef std::shared_ptr<TCPClient> 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