|
kmMqtt 0.0.1
MQTT Client Library
|
Base class for all MQTT packets. More...
#include <BasePacket.h>
Public Member Functions | |
| virtual PacketType | getPacketType () const noexcept=0 |
| Gets the packet type of the MQTT packet. | |
| EncodeResult | encode () |
| Encodes the MQTT packet into a ByteBuffer. | |
| DecodeResult | decode () |
| Decodes the MQTT packet from the internal data buffer. | |
| const FixedHeader & | getFixedHeader () const |
| Gets the fixed header of the MQTT packet. | |
| const ByteBuffer & | getDataBuffer () const |
| Gets the data buffer of the MQTT packet. | |
| ByteBuffer && | extractDataBuffer () noexcept |
| Extracts the data buffer, transferring ownership to the caller. | |
Protected Member Functions | |
| std::size_t | calculateFixedHeaderRemainingLength () const |
| Calculates the remaining length for the fixed header based on other headers. | |
| virtual void | onFixedHeaderDecoded () const |
| Callback invoked after the fixed header has been decoded. | |
| void | addEncodeHeader (const IEncodeHeader *header) |
| Adds an encode header to the packet. | |
| void | addDecodeHeader (IDecodeHeader *header) |
| Adds a decode header to the packet. | |
Base class for all MQTT packets.
Provides common functionality for encoding and decoding packets, managing fixed headers, and handling data buffers.
|
protected |
Adds a decode header to the packet.
The base packet does not take ownership of the header. Addition order matters! These are decoded in the order they are added.
| header | Pointer to the IDecodeHeader to add. |
|
protected |
Adds an encode header to the packet.
The base packet does not take ownership of the header. Addition order matters! These are encoded in the order they are added.
| header | Pointer to the IEncodeHeader to add. |
|
protected |
Calculates the remaining length for the fixed header based on other headers.
| DecodeResult kmMqtt::mqtt::BasePacket::decode | ( | ) |
Decodes the MQTT packet from the internal data buffer.
| EncodeResult kmMqtt::mqtt::BasePacket::encode | ( | ) |
Encodes the MQTT packet into a ByteBuffer.
|
noexcept |
Extracts the data buffer, transferring ownership to the caller.
| const ByteBuffer & kmMqtt::mqtt::BasePacket::getDataBuffer | ( | ) | const |
Gets the data buffer of the MQTT packet.
| const FixedHeader & kmMqtt::mqtt::BasePacket::getFixedHeader | ( | ) | const |
Gets the fixed header of the MQTT packet.
|
pure virtualnoexcept |
Gets the packet type of the MQTT packet.
Implemented in kmMqtt::mqtt::Connect, kmMqtt::mqtt::ConnectAck, kmMqtt::mqtt::Disconnect, kmMqtt::mqtt::PingReq, kmMqtt::mqtt::PingResp, kmMqtt::mqtt::Publish, kmMqtt::mqtt::PublishAck, kmMqtt::mqtt::PublishComp, kmMqtt::mqtt::PublishRec, kmMqtt::mqtt::PublishRel, kmMqtt::mqtt::Subscribe, kmMqtt::mqtt::SubscribeAck, kmMqtt::mqtt::UnSubscribe, and kmMqtt::mqtt::UnSubscribeAck.
|
protectedvirtual |
Callback invoked after the fixed header has been decoded.
Can be overridden by derived classes for additional processing thats required post fixed header decoding.
Reimplemented in kmMqtt::mqtt::Publish, kmMqtt::mqtt::PublishAck, kmMqtt::mqtt::PublishComp, kmMqtt::mqtt::PublishRec, and kmMqtt::mqtt::PublishRel.