system_communication.cpp 850 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by huli on 2020/6/28.
  3. //
  4. #include "system_communication.h"
  5. System_communication::System_communication()
  6. {
  7. }
  8. System_communication::~System_communication()
  9. {
  10. }
  11. //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
  12. Error_manager System_communication::encapsulate_send_data()
  13. {
  14. char buf[256] = {0};
  15. static unsigned int t_heartbeat = 0;
  16. sprintf(buf, "Communication_socket_base, heartbeat = %d\0\0\0", t_heartbeat);
  17. t_heartbeat++;
  18. Binary_buf* tp_buf = new Binary_buf(buf, strlen(buf)+1);//+1是为了保证发送了结束符, 方便打印
  19. bool is_push = m_send_data_list.push(tp_buf);
  20. if ( is_push == false )
  21. {
  22. return Error_manager(Error_code::CONTAINER_IS_TERMINATE, Error_level::MINOR_ERROR,
  23. " Communication_socket_base::encapsulate_msg error ");
  24. }
  25. return Error_code::SUCCESS;
  26. }