1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/examples/qqtnetworkexample/qqtnetworkmessage.h

57 lines
1.2 KiB
C
Raw Normal View History

2017-10-17 22:00:45 +08:00
#ifndef QQTNETWORKMESSAGE_H
#define QQTNETWORKMESSAGE_H
#include "qqtmessage.h"
#define _TCPCMD_TAGHEAD 0xAA55
#define _TCPCMD_TAGTAIL 0xCC33C33C
class QQTNetworkMessage : public QQtMessage
2017-10-17 22:00:45 +08:00
{
Q_OBJECT
public:
2018-01-15 09:08:57 +08:00
explicit QQTNetworkMessage ( QObject* parent = 0 );
2017-10-17 22:00:45 +08:00
const quint16& head() const;
2018-01-15 09:08:57 +08:00
void setHead ( quint16 head );
2017-10-17 22:00:45 +08:00
const quint16& size() const;
2018-01-15 09:08:57 +08:00
void setSize ( quint16 size );
2017-10-17 22:00:45 +08:00
const quint16& cmd() const;
2018-01-15 09:08:57 +08:00
void setCmd ( quint16 cmd );
2017-10-17 22:00:45 +08:00
const quint32& uid() const;
2018-01-15 09:08:57 +08:00
void setUid ( quint32 uid );
2017-10-17 22:00:45 +08:00
const QByteArray& data() const;
2018-01-15 09:08:57 +08:00
void setData ( QByteArray& data );
2017-10-17 22:00:45 +08:00
const quint16& sum() const;
2018-01-15 09:08:57 +08:00
void setSum ( quint16 sum );
2017-10-17 22:00:45 +08:00
const quint32& tail() const;
2018-01-15 09:08:57 +08:00
void setTail ( quint32 tail );
2017-10-17 22:00:45 +08:00
void translate();
signals:
public slots:
// QQtMessage interface
2017-10-17 22:00:45 +08:00
public:
2018-01-15 09:08:57 +08:00
void parser ( const QByteArray& l ) override;
2017-10-17 22:00:45 +08:00
2018-01-15 09:08:57 +08:00
void packer ( QByteArray& l ) const override;
2017-10-17 22:00:45 +08:00
private:
quint16 m_Head;
quint16 m_Size;
quint16 m_Cmd;
quint32 m_Uid;
QByteArray m_Data;
quint16 m_Sum;
quint32 m_Tail;
};
2018-01-15 09:08:57 +08:00
QDebug operator<< ( QDebug dbg, const QQTNetworkMessage& c );
2017-10-17 22:00:45 +08:00
#endif // QQTNETWORKMESSAGE_H