Files
boost_mqtt5/doc/qbk/reference/properties/will_props.qbk
T
Korina Šimičević 5034734fc4 expose CONNACK properties
Summary: resolves T13155

Reviewers: ivica

Reviewed By: ivica

Subscribers: miljen, iljazovic

Maniphest Tasks: T13155

Differential Revision: https://repo.mireo.local/D26681
2023-11-23 13:45:14 +01:00

55 lines
2.7 KiB
Plaintext

[/
Copyright (c) 2023 Mireo
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]
[section:will_props Will properties]
The Will Properties consist of the properties that determine when to publish the [reflink2 will Will] Message
and the Application Message properties to be sent with the [reflink2 will Will] Message.
The Will Properties consists of a Property Length and the Properties.
A Property consists of an Identifier and a value.
This section lists all possible [reflink2 will Will] Properties and describes their usage:
[table:will_props Will properties
[[Identifier] [Value type] [Description]]
[[will_delay_interval] [`int32_t`] [The delay in seconds that need to pass before Server publishes the Client's Will Message.]]
[[payload_format_indicator] [`uint8_t`] [Value of 0 indicates that the Will Message is in unspecified bytes. Value of 1 indicates that the Will Message is UTF-8 Encoded Character Data.]]
[[message_expiry_interval] [`int32_t`] [The lifetime of the Will Message in seconds. It is send as Publication Expiry Interval when it is published.]]
[[content_type] [`std::string`] [A UTF-8 Encoded String describing the content of the Will Message.]]
[[response_topic] [`std::string`] [A UTF-8 Encoded String which is used as the Topic Name for a response message.]]
[[correlation_data] [`std::string`] [Binary Data used by the sender of the Request Message to identify which request the Response Message is for when it is received.]]
[[user_property] [`std::vector<std::string>`] [A list of name, value pairs (__UTF8_STRING_PAIR__) defining User Properties.
The meaning of these properties is not defined by the specification.]]
]
[h4 Usage]
After creating an instance of [reflink2 will `async_mqtt5::will`], the subscript operator can be used to access a Property.
The Identifiers listed in the table above are available within the `async_mqtt5::prop` namespace for Property access.
[h4 Example]
The following example shows how to set a Property value:
[!c++]
async_mqtt5::will will;
will[async_mqtt5::prop::message_expiry_interval] = 90;
will[async_mqtt5::prop::content_type] = "Notification";
The following example shows how to retrieve a Property value:
[note When retrieving a property value, the subscript operator will consistently return a `std::optional` of the value type for all properties,
except for `async_mqtt5::prop::user_property`, where it will return an instance of its value type, `std::vector<std::string>`.]
[!c++]
std::optional<std::string> c_type = will[async_mqtt5::prop::content_type];
if (c_type.has_value())
// content type property was previously set
else
// content type property was not set
[endsect]