![]() |
PahoMqttCpp
MQTT C++ Client for POSIX and Windows
|
#include <topic.h>
Public Types | |
| using | ptr_t = std::shared_ptr<topic> |
| using | const_ptr_t = std::shared_ptr<const topic> |
Public Member Functions | |
| topic (iasync_client &cli, const string &name, int qos=message::DFLT_QOS, bool retained=message::DFLT_RETAINED) | |
| iasync_client & | get_client () |
| const string & | get_name () const |
| int | get_qos () const |
| bool | get_retained () const |
| void | set_qos (int qos) |
| void | set_retained (bool retained) |
| delivery_token_ptr | publish (const void *payload, size_t n) |
| delivery_token_ptr | publish (const void *payload, size_t n, int qos, bool retained) |
| delivery_token_ptr | publish (binary_ref payload) |
| delivery_token_ptr | publish (binary_ref payload, int qos, bool retained) |
| token_ptr | subscribe (const subscribe_options &opts=subscribe_options()) |
| string | to_string () const |
Static Public Member Functions | |
| static ptr_t | create (iasync_client &cli, const string &name, int qos=message::DFLT_QOS, bool retained=message::DFLT_RETAINED) |
| static std::vector< std::string > | split (const std::string &topic) |
Represents a topic destination, used for publish/subscribe messaging.
This is primarily a convenience class for publishing multiple messages to the same topic. It holds all the parameters for publishing the message other than the payload: topic, QoS, and retain flag. Each publish operation then only needs to supply the payload.
It can also be used to subscribe to the specific topic, but this is not the normal use case.
| using mqtt::topic::ptr_t = std::shared_ptr<topic> |
A smart/shared pointer to this class.
| using mqtt::topic::const_ptr_t = std::shared_ptr<const topic> |
A smart/shared pointer to this class.
|
inline |
Construct an MQTT topic destination for messages.
| cli | Client to which the topic is attached |
| name | The topic string |
| qos | The default QoS for publishing. |
| retained | The default retained flag for the topic. |
|
inlinestatic |
Creates a new topic.
| cli | Client to which the topic is attached |
| name | The topic string |
| qos | The default QoS for publishing. |
| retained | The default retained flag for the topic. |
|
inline |
Gets a reference to the MQTT client used by this topic.
|
inline |
Gets the name of the topic.
|
static |
Splits a topic string into individual fields.
| topic | A slash-delimited MQTT topic string. |
|
inline |
Gets the default quality of service for this topic.
|
inline |
Gets the default retained flag used for this topic.
|
inline |
Sets the default quality of service for this topic.
| qos | The default quality of service for this topic. |
|
inline |
Sets the default retained flag used for this topic.
| retained | The default retained flag used for this topic. |
| delivery_token_ptr mqtt::topic::publish | ( | const void * | payload, |
| size_t | n ) |
Publishes a message on the topic using the default QoS and retained flag.
| payload | the bytes to use as the message payload |
| n | the number of bytes in the payload |
| delivery_token_ptr mqtt::topic::publish | ( | const void * | payload, |
| size_t | n, | ||
| int | qos, | ||
| bool | retained ) |
Publishes a message on the topic.
| payload | the bytes to use as the message payload |
| n | the number of bytes in the payload |
| qos | the Quality of Service to deliver the message at. Valid values are 0, 1 or 2. |
| retained | whether or not this message should be retained by the server. |
| delivery_token_ptr mqtt::topic::publish | ( | binary_ref | payload | ) |
Publishes a message on the topic using the default QoS and retained flag.
| payload | the bytes to use as the message payload |
| delivery_token_ptr mqtt::topic::publish | ( | binary_ref | payload, |
| int | qos, | ||
| bool | retained ) |
Publishes a message on the topic.
| payload | the bytes to use as the message payload |
| qos | the Quality of Service to deliver the message at. Valid values are 0, 1 or 2. |
| retained | whether or not this message should be retained by the server. |
| token_ptr mqtt::topic::subscribe | ( | const subscribe_options & | opts = subscribe_options() | ) |
Subscribe to the topic.
|
inline |
Returns a string representation of this topic.