SNode.C
Loading...
Searching...
No Matches
ControlPacket.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef IOT_MQTTFAST_CONTROLPACKET_H
21#define IOT_MQTTFAST_CONTROLPACKET_H
22
23#include "iot/mqtt-fast/types/Binary.h"
24
25namespace iot::mqtt_fast {
27} // namespace iot::mqtt_fast
28
29#ifndef DOXYGEN_SHOULD_SKIP_THIS
30
31#include <cstdint>
32#include <list>
33#include <string>
34#include <vector>
35
36#endif // DOXYGEN_SHOULD_SKIP_THIS
37
38namespace iot::mqtt_fast {
39
41 public:
42 explicit ControlPacket(uint8_t type, uint8_t reserved = 0);
43 explicit ControlPacket(iot::mqtt_fast::ControlPacketFactory& controlPacketFactory);
44
45 ControlPacket(const ControlPacket&) = delete;
47
50
51 uint8_t getType() const;
52 uint8_t getReserved() const;
53 uint64_t getRemainingLength() const;
54 std::vector<char> getPacket();
55
56 bool isError() const;
57
58 protected:
59 std::vector<char>& getValue();
60
61 uint8_t getInt8();
62 uint16_t getInt16();
63 uint32_t getInt32();
64 uint64_t getInt64();
65 uint32_t getIntV();
66 std::string getString();
67 std::string getStringRaw();
69
70 void putInt8(uint8_t value);
71 void putInt16(uint16_t value);
72 void putInt32(uint32_t value);
73 void putInt64(uint64_t value);
74 void putIntV(uint32_t value);
75 void putString(const std::string& value);
76 void putStringRaw(const std::string& value);
77 void putUint8ListRaw(const std::list<uint8_t>& value);
78
79 bool isError();
80
81 private:
82 uint8_t type;
83 uint8_t reserved;
84
86
87 protected:
88 bool error = false;
89 };
90
91} // namespace iot::mqtt_fast
92
93#endif // IOT_MQTTFAST_CONTROLPACKET_H
std::vector< char > getPacket()
ControlPacket(ControlPacket &&)=delete
ControlPacket & operator=(ControlPacket &&)=delete
ControlPacket(iot::mqtt_fast::ControlPacketFactory &controlPacketFactory)
void putInt16(uint16_t value)
void putString(const std::string &value)
ControlPacket(const ControlPacket &)=delete
iot::mqtt_fast::types::Binary data
ControlPacket(uint8_t type, uint8_t reserved=0)
void putStringRaw(const std::string &value)
uint64_t getRemainingLength() const
void putInt32(uint32_t value)
std::list< uint8_t > getUint8ListRaw()
void putUint8ListRaw(const std::list< uint8_t > &value)
void putInt64(uint64_t value)
ControlPacket & operator=(const ControlPacket &)=delete
std::vector< char > & getValue()
Connack(uint8_t reason, uint8_t flags)
Definition Connack.cpp:28
Connack(mqtt_fast::ControlPacketFactory &controlPacketFactory)
Definition Connack.cpp:39
#define MQTT_CONNACK
Definition Connack.h:35