Loading...
Searching...
No Matches
mqtt::create_options Class Reference

`#include <create_options.h>`

## Public Types

using | ptr_t = std::shared_ptr< create_options >
using | const_ptr_t = std::shared_ptr< const create_options >

## Public Member Functions

| create_options ()
| create_options (int mqttVersion)
| create_options (int mqttVersion, int maxBufferedMessages)
| create_options (const string &serverURI, const string &clientId=string{}, const persistence_type &persistence=NO_PERSISTENCE)
| create_options (const string &serverURI, const string &clientId, int maxBufferedMessages, const persistence_type &persistence=NO_PERSISTENCE)
| create_options (const string &serverURI, const string &clientId, const create_options &opts, const persistence_type &persistence)
| create_options (const create_options &opts)
| create_options (create_options &&opts)
create_options & | operator= (const create_options &rhs)
create_options & | operator= (create_options &&rhs)
void | set_server_uri (const string &serverURI)
const string & | get_server_uri () const noexcept
void | set_client_id (const string &clientId)
const string & | get_client_id () const noexcept
void | set_persistence (const persistence_type &persistence)
const persistence_type & | get_persistence () const noexcept
bool | get_send_while_disconnected () const
void | set_send_while_disconnected (bool on, bool anyTime=false)
int | get_max_buffered_messages () const
void | set_max_buffered_messages (int n)
int | mqtt_version () const
void | set_mqtt_version (int ver)
bool | get_delete_oldest_messages () const
void | set_delete_oldest_messages (bool on)
bool | get_restore_messages () const
void | set_restore_messages (bool on)
bool | get_persist_qos0 () const
void | set_persist_qos0 (bool on)

## Friends

class | async_client
class | create_options_builder

## Detailed Description

The set of options for constructing a client object.

Note that the numerous, incomplete set of constructors pre-date the current, expanded, options structure. For a full set of create options, a builder can be used to specify the options, then construct the client with those options, like this:

auto createOpts = mqtt::create_options_builder()
.server_uri(serverURI)
.send_while_disconnected()
.max_buffered_messages(25)
.delete_oldest_messages()
.finalize();
mqtt::async_client cli(createOpts);
mqtt::async_client
Definition async_client.h:137
mqtt::create_options_builder
Definition create_options.h:318
mqtt::create_options_builder::server_uri
auto server_uri(const string &serverURI) -> self &
Definition create_options.h:334

## Member Typedef Documentation

## ptr_t

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

Smart/shared pointer to an object of this class.

## const_ptr_t

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

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

## Constructor & Destructor Documentation

## create_options() [1/8]

mqtt::create_options::create_options | ( |  | ) |

inline

Default set of client create options.

## create_options() [2/8]

mqtt::create_options::create_options | ( | int | mqttVersion | ) |

inline explicit

Default create options for the specified version of MQTT.

Parameters

  mqttVersion | The MQTT version used to create the client.

## create_options() [3/8]

mqtt::create_options::create_options | ( | int | mqttVersion,
|  | int | maxBufferedMessages
| ) |  |

Default create options, but with off-line buffering enabled.

Parameters

  mqttVersion | The MQTT version used to create the client.
  maxBufferedMessages | the maximum number of messages allowed to be buffered while not connected

## create_options() [4/8]

mqtt::create_options::create_options | ( | const string & | serverURI,
|  | const string & | clientId = `string{}`,
|  | const persistence_type & | persistence = `NO_PERSISTENCE`
| ) |  |

inline explicit

Create options for the specified server and client ID, with optional persistence. This allows the caller to specify a user-defined persistence object, or use no persistence.

Parameters

  serverURI | the address of the server to connect to, specified as a URI.
  clientId | a client identifier that is unique on the server being connected to
  persistence | The desired persistence structure.

Exceptions

  exception | if an argument is invalid

## create_options() [5/8]

mqtt::create_options::create_options | ( | const string & | serverURI,
|  | const string & | clientId,
|  | int | maxBufferedMessages,
|  | const persistence_type & | persistence = `NO_PERSISTENCE`
| ) |  |

inline

Create an async_client that can be used to communicate with an MQTT server, which allows for off-line message buffering. This uses file-based persistence in the specified directory.

Parameters

  serverURI | the address of the server to connect to, specified as a URI.
  clientId | a client identifier that is unique on the server being connected to
  maxBufferedMessages | the maximum number of messages allowed to be buffered while not connected
  persistence | The persistence that the client should use.

Exceptions

  exception | if an argument is invalid

## create_options() [6/8]

mqtt::create_options::create_options | ( | const string & | serverURI,
|  | const string & | clientId,
|  | const create_options & | opts,
|  | const persistence_type & | persistence
| ) |  |

inline

Create an async_client that can be used to communicate with an MQTT server, which allows for off-line message buffering. This uses file-based persistence in the specified directory.

Parameters

  serverURI | the address of the server to connect to, specified as a URI.
  clientId | a client identifier that is unique on the server being connected to
  opts | The create options
  persistence | The persistence that the client should use.

Exceptions

  exception | if an argument is invalid

## create_options() [7/8]

mqtt::create_options::create_options | ( | const create_options & | opts | ) |

inline

Copy constructor.

Parameters

  opts | The other options.

## create_options() [8/8]

mqtt::create_options::create_options | ( | create_options && | opts | ) |

inline

Move constructor.

Parameters

  opts | The other options.

## Member Function Documentation

## operator=() [1/2]

create_options & mqtt::create_options::operator= | ( | const create_options & | rhs | ) |

## operator=() [2/2]

create_options & mqtt::create_options::operator= | ( | create_options && | rhs | ) |

## set_server_uri()

void mqtt::create_options::set_server_uri | ( | const string & | serverURI | ) |

inline

Set the address of the server to connect to, specified as a URI

Parameters

  serverURI | The URI of the server.

## get_server_uri()

const string & mqtt::create_options::get_server_uri | ( |  | ) | const

inline noexcept

Get the address of the server to connect to, specified as a URI.

Returns
  The URI of the server.

## set_client_id()

void mqtt::create_options::set_client_id | ( | const string & | clientId | ) |

inline

Set the client identifier.

Parameters

  clientId | The client identifier.

## get_client_id()

const string & mqtt::create_options::get_client_id | ( |  | ) | const

inline noexcept

Get the client identifier.

Returns
  The client identifier.

## set_persistence()

void mqtt::create_options::set_persistence | ( | const persistence_type & | persistence | ) |

inline

Set the persistence for the client.

Parameters

  persistence | The persistence for the client

## get_persistence()

const persistence_type & mqtt::create_options::get_persistence | ( |  | ) | const

inline noexcept

Get the persistence for the client.

Returns
  The persistence for the client

## get_send_while_disconnected()

bool mqtt::create_options::get_send_while_disconnected | ( |  | ) | const

inline

Gets whether the client will accept message to publish while disconnected.

## set_send_while_disconnected()

void mqtt::create_options::set_send_while_disconnected | ( | bool | on,
|  | bool | anyTime = `false`
| ) |  |

inline

Sets whether the client will accept message to publish while disconnected.

Parameters

  on | true to allow the application to publish messages while disconnected, false returns an error on publish if disconnected.
  anyTime | If true, allows you to publish messages before the first successful connection.

## get_max_buffered_messages()

int mqtt::create_options::get_max_buffered_messages | ( |  | ) | const

inline

Gets the maximum number of offline buffered messages.

Returns
  The maximum number of offline buffered messages.

## set_max_buffered_messages()

void mqtt::create_options::set_max_buffered_messages | ( | int | n | ) |

inline

Sets the maximum number of offline buffered messages.

Parameters

  n | The maximum number of offline buffered messages.

## mqtt_version()

int mqtt::create_options::mqtt_version | ( |  | ) | const

inline

Gets the MQTT version used to create the client.

Returns
  The MQTT version used to create the client.

## set_mqtt_version()

void mqtt::create_options::set_mqtt_version | ( | int | ver | ) |

inline

Sets the MQTT version used to create the client.

Parameters

  ver | The MQTT version used to create the client.

## get_delete_oldest_messages()

bool mqtt::create_options::get_delete_oldest_messages | ( |  | ) | const

inline

Whether the oldest messages are deleted when the output buffer is full.

Returns
  true if the oldest messages should be deleted when the output buffer is full, false if the new messages should be dropped when the buffer is full.

## set_delete_oldest_messages()

void mqtt::create_options::set_delete_oldest_messages | ( | bool | on | ) |

inline

Determines what to do when the maximum number of buffered messages is reached: delete the oldest messages rather than the newest

Parameters

  on | true When the output queue is full, delete the oldest message, false drop the newest message being added.

## get_restore_messages()

bool mqtt::create_options::get_restore_messages | ( |  | ) | const

inline

Whether the messages will be restored from persistence or the store will be cleared.

Returns
  true if the messages will be restored from persistence, false if the persistence store will be cleared.

## set_restore_messages()

void mqtt::create_options::set_restore_messages | ( | bool | on | ) |

inline

Determine whether to restore messages from persistence or clear the persistence store.

Parameters

  on | true to restore messages from persistence, false to clear the persistence store.

## get_persist_qos0()

bool mqtt::create_options::get_persist_qos0 | ( |  | ) | const

inline

Whether to persist QoS 0 messages.

Returns
  true if QoS 0 messages are persisted, false if not.

## set_persist_qos0()

void mqtt::create_options::set_persist_qos0 | ( | bool | on | ) |

inline

Determine whether to persist QoS 0 messages.

Parameters

  on | true if QoS 0 messages are persisted, false if not.

## Friends And Related Symbol Documentation

## async_client

friend class async_client

friend

The client and tests have special access

## create_options_builder

friend class create_options_builder

friend

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

- create_options.h