confirm_process.py 833 B

12345678910111213141516171819202122232425262728293031323334
  1. """
  2. 确认消息处理策略
  3. """
  4. from utils.logger import logger
  5. from .base_strategy import ProcessStrategy
  6. class ConfirmProcess(ProcessStrategy):
  7. """确认消息处理类"""
  8. def process(self, client_socket, msg_id: int) -> bool:
  9. """
  10. 发送确认消息
  11. Args:
  12. client_socket: 客户端socket
  13. msg_id: 消息ID
  14. Returns:
  15. bool: 处理结果
  16. """
  17. try:
  18. temp = bytearray()
  19. temp.append(0xa5)
  20. temp.append(0x00)
  21. temp.append(0x00)
  22. temp.append(0x00)
  23. send_data = self.makepacket(msg_id, 0xff, temp)
  24. client_socket.send(send_data)
  25. return True
  26. except Exception as e:
  27. logger.info(f"发送确认消息失败: {e}")
  28. return False