pqtcpsocket.h 582 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef PQ_PQTCPSOCKET_H
  2. #define PQ_PQTCPSOCKET_H
  3. #include <QTcpSocket>
  4. #include "pqmsgheader.h"
  5. /**
  6. 处理分包soket封装
  7. */
  8. namespace PQ {
  9. class PQTcpSocket : public QTcpSocket
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit PQTcpSocket(QObject *parent = Q_NULLPTR);
  14. ~PQTcpSocket();
  15. public slots:
  16. // 写心消息
  17. void writeMessage(MSGHeader header, const QByteArray & byte);
  18. signals:
  19. void revicedMSG(const MSGHeader & header, QByteArray body);
  20. private slots:
  21. void msgError();
  22. void readSocketData();
  23. private:
  24. MSGRead _msg;
  25. };
  26. }
  27. #endif // PQTCPSOCKET_H