1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QMQTTCONTROLPACKET_P_H
5#define QMQTTCONTROLPACKET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17#include "qmqttglobal.h"
18
19#include <QtCore/QByteArray>
20#include <QtCore/QtGlobal>
21#include <QtCore/private/qglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class Q_AUTOTEST_EXPORT QMqttControlPacket
26{
27public:
28 enum PacketType {
29 UNKNOWN = 0x00,
30 CONNECT = 0x10,
31 CONNACK = 0x20,
32 PUBLISH = 0x30,
33 PUBACK = 0x40,
34 PUBREC = 0x50,
35 PUBREL = 0x60,
36 PUBCOMP = 0x70,
37 SUBSCRIBE = 0x80,
38 SUBACK = 0x90,
39 UNSUBSCRIBE = 0xA0,
40 UNSUBACK = 0xB0,
41 PINGREQ = 0xC0,
42 PINGRESP = 0xD0,
43 DISCONNECT = 0xE0,
44 AUTH = 0xF0,
45 };
46
47 QMqttControlPacket();
48 QMqttControlPacket(quint8 header);
49 QMqttControlPacket(quint8 header, const QByteArray &pay);
50
51 void clear();
52
53 void setHeader(quint8 h);
54 inline quint8 header() const { return m_header; }
55
56 void append(char value);
57 void append(quint16 value);
58 void append(quint32 value);
59 void append(const QByteArray &data);
60 void appendRaw(const QByteArray &data);
61 void appendRawVariableInteger(quint32 value);
62
63 QByteArray serialize() const;
64 QByteArray serializePayload() const;
65 inline QByteArray payload() const { return m_payload; }
66private:
67 quint8 m_header{UNKNOWN};
68 QByteArray m_payload;
69};
70
71QT_END_NAMESPACE
72
73#endif // QMQTTCONTROLPACKET_P_H
74

source code of qtmqtt/src/mqtt/qmqttcontrolpacket_p.h