forked from boostorg/mqtt5
Summary: resolves T13155 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Maniphest Tasks: T13155 Differential Revision: https://repo.mireo.local/D26681
48 lines
1.9 KiB
Plaintext
48 lines
1.9 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:pubcomp_props PUBCOMP properties]
|
|
The last field in the Variable header of __PUBCOMP__ packet is a set of Properties.
|
|
A set contains a Property Length followed by the Properties.
|
|
A Property consists of an Identifier and a value.
|
|
|
|
This section lists all possible __PUBCOMP__ Properties and describes their usage:
|
|
|
|
[table:pubcomp_props PUBCOMP properties
|
|
[[Identifier] [Value type] [Description]]
|
|
[[reason_string] [`std::string`] [A UTF-8 Encoded String representing the reason associated with this response.]]
|
|
[[user_property] [`std::vector<std::string>`] [A list of name, value pairs (__UTF8_STRING_PAIR__) defining User Properties.
|
|
This property may be used to provide additional diagnostic or other information. ]]
|
|
]
|
|
|
|
[h4 Usage]
|
|
After obtaining an instance of `async_mqtt5::pubcomp_props`, 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::pubcomp_props props;
|
|
props[async_mqtt5::prop::reason_string] = "Some reason...";
|
|
|
|
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> reason_string = props[async_mqtt5::prop::reason_string];
|
|
if (reason_string.has_value())
|
|
// reason string property was previously set
|
|
else
|
|
// reason string property was not set
|
|
|
|
[endsect]
|