TCPClient.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * @Description: TCPClient
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2021-09-13 17:30:20
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2021-10-13 09:41:07
  8. */
  9. #pragma once
  10. #include <signal.h>
  11. #include <iostream>
  12. #include "Util/logger.h"
  13. #include "Network/TcpClient.h"
  14. #include "Util/NoticeCenter.h"
  15. #include "Notices.h"
  16. using namespace std;
  17. using namespace toolkit;
  18. // dataType
  19. #include "SendLogin.h"
  20. #include "NettyServerCommandEnum.h"
  21. #include "NettyServerResultMsg.h"
  22. #include "NettyClientResultMsg.h"
  23. #include "SendLogin.h"
  24. #include "NettyClientCommandEnum.h"
  25. #include "SendHeartBeat.h"
  26. namespace MIVA
  27. {
  28. class TCPClient: public TcpClient
  29. {
  30. private:
  31. /* data */
  32. public:
  33. typedef std::shared_ptr<TCPClient> Ptr;
  34. TCPClient():TcpClient() {
  35. DebugL;
  36. }
  37. ~TCPClient(){
  38. DebugL;
  39. }
  40. protected:
  41. virtual void onConnect(const SockException &ex) override;
  42. virtual void onRecv(const Buffer::Ptr &pBuf) override;
  43. virtual void onFlush() override;
  44. virtual void onErr(const SockException &ex) override;
  45. virtual void onManager() override;
  46. private:
  47. int _nTick = 0;
  48. std::string _IP;
  49. int32_t _port;
  50. };
  51. } // namespace VIA