paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends
mqtt::subscribe_options Class Reference

#include <subscribe_options.h>

Public Types

enum  RetainHandling { SEND_RETAINED_ON_SUBSCRIBE = 0 , SEND_RETAINED_ON_NEW = 1 , DONT_SEND_RETAINED = 2 }
 
using ptr_t = std::shared_ptr< subscribe_options >
 
using const_ptr_t = std::shared_ptr< const subscribe_options >
 

Public Member Functions

 subscribe_options ()
 
 subscribe_options (bool noLocal, byte retainAsPublished=false, RetainHandling retainHandling=SEND_RETAINED_ON_SUBSCRIBE)
 
bool get_no_local () const
 
void set_no_local (bool on=true)
 
bool get_retain_as_published () const
 
void set_retain_as_published (bool on)
 
auto get_retain_handling () const -> RetainHandling
 
void set_retain_handling (RetainHandling retainHandling)
 

Static Public Attributes

static PAHO_MQTTPP_EXPORT const bool SUBSCRIBE_NO_LOCAL
 
static PAHO_MQTTPP_EXPORT const bool SUBSCRIBE_LOCAL
 
static PAHO_MQTTPP_EXPORT const bool NO_RETAIN_AS_PUBLISHED
 
static PAHO_MQTTPP_EXPORT const bool RETAIN_AS_PUBLISHED
 

Friends

class async_client
 
class response_options
 

Detailed Description

The MQTT v5 subscription options. These are defined in section 3.8.3.1 of the MQTT v5 spec. The defaults use the behavior that was present in MQTT v3.1.1.

Member Typedef Documentation

◆ ptr_t

Smart/shared pointer to an object of this class.

◆ const_ptr_t

Smart/shared pointer to a const object of this class.

Member Enumeration Documentation

◆ RetainHandling

The options for subscription retain handling

Enumerator
SEND_RETAINED_ON_SUBSCRIBE 

Send retained messages at the time of the subscribe

SEND_RETAINED_ON_NEW 

Send retained messages on subscribe only if subscription is new

DONT_SEND_RETAINED 

Do not send retained messages at all

Constructor & Destructor Documentation

◆ subscribe_options() [1/2]

mqtt::subscribe_options::subscribe_options ( )
inline

Create default subscription options. These are the default options corresponding to the original MQTT (v3) behaviors.

◆ subscribe_options() [2/2]

mqtt::subscribe_options::subscribe_options ( bool  noLocal,
byte  retainAsPublished = false,
RetainHandling  retainHandling = SEND_RETAINED_ON_SUBSCRIBE 
)
inlineexplicit

Creates a set of subscription options.

Parameters
noLocalWhether the server should send back our own publications, if subscribed.
retainAsPublishedWhether to keep the retained flag as in the original published message (true).
retainHandlingWhen to send retained messages:
  • (SEND_RETAINED_ON_SUBSCRIBE, 0) At the time of the subscribe
  • (SEND_RETAINED_ON_NEW, 1) Only at the time of a new subscribe
  • (DONT_SEND_RETAINED, 2) Not at the time of subscribe

Member Function Documentation

◆ get_no_local()

bool mqtt::subscribe_options::get_no_local ( ) const
inline

Gets the value of the "no local" flag.

Returns
Whether the server should send back our own publications, if subscribed.

◆ set_no_local()

void mqtt::subscribe_options::set_no_local ( bool  on = true)
inline

Sets the "no local" flag on or off.

Parameters
onWhether the server should send back our own publications, if subscribed.

◆ get_retain_as_published()

bool mqtt::subscribe_options::get_retain_as_published ( ) const
inline

Gets the "retain as published" flag.

Returns
Whether to keep the retained flag as in the original published message.

◆ set_retain_as_published()

void mqtt::subscribe_options::set_retain_as_published ( bool  on)
inline

Sets the "retain as published" flag on or off.

Parameters
onWhether to keep the retained flag as in the original published message.

◆ get_retain_handling()

auto mqtt::subscribe_options::get_retain_handling ( ) const -> RetainHandling
inline

Gets the "retain handling" option.

Returns
When to send retained messages:
  • (SEND_RETAINED_ON_SUBSCRIBE, 0) At the time of the subscribe
  • (SEND_RETAINED_ON_NEW, 1) Only at the time of a new subscribe
  • (DONT_SEND_RETAINED, 2) Not at the time of subscribe

◆ set_retain_handling()

void mqtt::subscribe_options::set_retain_handling ( RetainHandling  retainHandling)
inline

Sets the "retain handling" option.

Parameters
retainHandlingWhen to send retained messages:
  • (SEND_RETAINED_ON_SUBSCRIBE, 0) At the time of the subscribe
  • (SEND_RETAINED_ON_NEW, 1) Only at the time of a new subscribe
  • (DONT_SEND_RETAINED, 2) Not at the time of subscribe

Friends And Related Symbol Documentation

◆ async_client

friend class async_client
friend

The client and response have special access

◆ response_options

friend class response_options
friend

Field Documentation

◆ SUBSCRIBE_NO_LOCAL

PAHO_MQTTPP_EXPORT const bool mqtt::subscribe_options::SUBSCRIBE_NO_LOCAL
static

Don't receive our own publications

◆ SUBSCRIBE_LOCAL

PAHO_MQTTPP_EXPORT const bool mqtt::subscribe_options::SUBSCRIBE_LOCAL
static

Receive our own publications

◆ NO_RETAIN_AS_PUBLISHED

PAHO_MQTTPP_EXPORT const bool mqtt::subscribe_options::NO_RETAIN_AS_PUBLISHED
static

Retain flag is only set on publications sent by a broker if in response to a subscribe request

◆ RETAIN_AS_PUBLISHED

PAHO_MQTTPP_EXPORT const bool mqtt::subscribe_options::RETAIN_AS_PUBLISHED
static

Keep the retain flag as on the original publish message


The documentation for this class was generated from the following file: