IoT::MQTT

struct Message

File Information

Library: IoT/MQTT
Package: MQTTClient
Header: IoT/MQTT/Types.h

Description

This structure encapsulates a MQTT message.

Constructors

Message inline

Message();

Message inline

explicit Message(
    int q
);

Message inline

Message(
    const std::string & p,
    int q
);

Message inline

Message(
    const std::vector < char > & p,
    int q
);

Message inline

Message(
    std::string && p,
    int q
);

Message inline

Message(
    std::vector < char > && p,
    int q
);

Variables

binaryPayload

std::vector < char > binaryPayload;

Alternative binary payload, considered if payload is empty.

payload

std::string payload;

The payload of the MQTT message.

properties

std::vector < Property > properties;

The MQTT V5 properties associated with this message.

qos

int qos = 0;

The quality of service (QoS) assigned to the message. There are three levels of QoS:

  • 0: Fire and forget - the message may not be delivered.
  • 1: At least once - the message will be delivered, but may be delivered more than once in some circumstances.
  • 2: Once and one only - the message will be delivered exactly once.

retained

bool retained = false;

The retained flag serves two purposes depending on whether the message it is associated with is being published or received.

  • retained = true: For messages being published, a true setting indicates that the MQTT server should retain a copy of the message. The message will then be transmitted to new subscribers to a topic that matches the message topic. For subscribers registering a new subscription, the flag being true indicates that the received message is not a new one, but one that has been retained by the MQTT server.
  • retained = false: For publishers, this indicates that this message should not be retained by the MQTT server. For subscribers, a false setting indicates this is a normal message, received as a result of it being published to the server.
Securely control IoT edge devices from anywhere   Connect a Device