ttu_client.h 917 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <string>
  3. #include "base/define.h"
  4. #include "base/buffer.h"
  5. #include "util/map.hpp"
  6. namespace ylib::network::tcp { class server; }
  7. class UdpClientListener;
  8. namespace ylib
  9. {
  10. namespace network
  11. {
  12. class ttu_client
  13. {
  14. public:
  15. struct Packages : public std::vector<ylib::buffer>
  16. {
  17. };
  18. public:
  19. ttu_client();
  20. ~ttu_client();
  21. bool start(const ylib::AddressPort& listen);
  22. void close();
  23. // 设置远程地址
  24. void setRemoteAP(const ylib::AddressPort& remote_ap) { m_remote_ap = remote_ap; }
  25. void setMacConnectionCount(int count = -1) { m_max_connection_count = count; }
  26. size_t getConnectionCount();
  27. friend class UdpClientListener;
  28. public:
  29. ylib::AddressPort m_remote_ap;
  30. ylib::network::tcp::server* m_server = nullptr;
  31. // 待发送
  32. ylib::map<uint64, Packages*> m_wait_send_data;
  33. // 最大连接数
  34. int m_max_connection_count = -1;
  35. };
  36. }
  37. }