Loading...
Searching...
No Matches
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, bool retainAsPublished=false, RetainHandling retainHandling=SEND_RETAINED_ON_SUBSCRIBE)
| subscribe_options (MQTTSubscribe_options opts)
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=true)
auto | get_retain_handling () const -> RetainHandling
void | set_retain_handling (RetainHandling retainHandling)

## Static Public Attributes

static constexpr bool | NO_LOCAL = true
static constexpr bool | LOCAL = false
static constexpr bool | SUBSCRIBE_NO_LOCAL = true
static constexpr bool | SUBSCRIBE_LOCAL = false
static constexpr bool | NO_RETAIN_AS_PUBLISHED = false
static constexpr bool | RETAIN_AS_PUBLISHED = true

## Friends

class | async_client
class | response_options

## Detailed Description

The MQTT v5 subscription options.

The subscribe options are bitfields in the payload of a SUBSCRIBE packet, forming a single options byte for each topic filter in the subscription.

These were added in MQTT v5. The default (zero/false) value for each field gives the behavior that was present in MQTT v3.1.1. To get a new behavior the field(s) must be set.

These are defined in section 3.8.3.1 of the MQTT v5 spec.

## Member Typedef Documentation

## ptr_t

using mqtt::subscribe_options::ptr_t = std::shared_ptr<subscribe_options>

Smart/shared pointer to an object of this class.

## const_ptr_t

using mqtt::subscribe_options::const_ptr_t = std::shared_ptr<const subscribe_options>

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

## Member Enumeration Documentation

## RetainHandling

enum mqtt::subscribe_options::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/3]

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/3]

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

inline explicit

Creates a set of subscription options.

Parameters

  noLocal | Whether the server should send back our own publications, if subscribed.
  retainAsPublished | Whether to keep the retained flag as in the original published message (true).

  retainHandling

  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

## subscribe_options() [3/3]

mqtt::subscribe_options::subscribe_options | ( | MQTTSubscribe_options | opts | ) |

inline explicit

Creates the set of subscribe options from an underlying C struct.

Parameters

  opts | The Paho C subscribe options

## 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

  on | Whether 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 = true | ) |

inline

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

Parameters

  on | Whether 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

  retainHandling

  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

## 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

## NO_LOCAL

bool mqtt::subscribe_options::NO_LOCAL = true

static constexpr

Don't receive our own publications

## LOCAL

bool mqtt::subscribe_options::LOCAL = false

static constexpr

Receive our own publications

## SUBSCRIBE_NO_LOCAL

bool mqtt::subscribe_options::SUBSCRIBE_NO_LOCAL = true

static constexpr

Deprecated
  Don't receive our own publications

## SUBSCRIBE_LOCAL

bool mqtt::subscribe_options::SUBSCRIBE_LOCAL = false

static constexpr

Deprecated
  Receive our own publications (obsolete name)

## NO_RETAIN_AS_PUBLISHED

bool mqtt::subscribe_options::NO_RETAIN_AS_PUBLISHED = false

static constexpr

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

## RETAIN_AS_PUBLISHED

bool mqtt::subscribe_options::RETAIN_AS_PUBLISHED = true

static constexpr

Keep the retain flag as on the original publish message

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

- subscribe_options.h