PahoMqttCpp
MQTT C++ Client for POSIX and Windows
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends
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{})
 
 create_options (const string &serverURI, const string &clientId, const persistence_type &persistence)
 
 create_options (const string &serverURI, const string &clientId, int maxBufferedMessages, const persistence_type &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_optionsoperator= (const create_options &rhs)
 
create_optionsoperator= (create_options &&rhs)
 
void set_server_uri (const string &serverURI)
 
const stringget_server_uri () const noexcept
 
void set_client_id (const string &clientId)
 
const stringget_client_id () const noexcept
 
void set_persistence (const persistence_type &persistence)
 
const persistence_typeget_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

Options for creating a client object.

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

mqtt::create_options::create_options ( )
inline

Default set of client create options.

◆ create_options() [2/9]

mqtt::create_options::create_options ( int  mqttVersion)
inlineexplicit

Default create options for the specified version of MQTT.

Parameters
mqttVersionThe MQTT version used to create the client.

◆ create_options() [3/9]

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

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

Parameters
mqttVersionThe MQTT version used to create the client.
maxBufferedMessagesthe maximum number of messages allowed to be buffered while not connected

◆ create_options() [4/9]

mqtt::create_options::create_options ( const string serverURI,
const string clientId = string{} 
)
inlineexplicit

Cretae options for the specified server and client ID. This uses file-based persistence in the specified directory.

Parameters
serverURIthe address of the server to connect to, specified as a URI.
clientIda client identifier that is unique on the server being connected to
Exceptions
exceptionif an argument is invalid

◆ create_options() [5/9]

mqtt::create_options::create_options ( const string serverURI,
const string clientId,
const persistence_type persistence 
)
inline

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
serverURIthe address of the server to connect to, specified as a URI.
clientIda client identifier that is unique on the server being connected to
persistenceThe desired persistence structure.
Exceptions
exceptionif an argument is invalid

◆ create_options() [6/9]

mqtt::create_options::create_options ( const string serverURI,
const string clientId,
int  maxBufferedMessages,
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
serverURIthe address of the server to connect to, specified as a URI.
clientIda client identifier that is unique on the server being connected to
maxBufferedMessagesthe maximum number of messages allowed to be buffered while not connected
persistenceThe persistence that the client should use.
Exceptions
exceptionif an argument is invalid

◆ create_options() [7/9]

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
serverURIthe address of the server to connect to, specified as a URI.
clientIda client identifier that is unique on the server being connected to
optsThe create options
persistenceThe persistence that the client should use.
Exceptions
exceptionif an argument is invalid

◆ create_options() [8/9]

mqtt::create_options::create_options ( const create_options opts)
inline

Copy constructor.

Parameters
optsThe other options.

◆ create_options() [9/9]

mqtt::create_options::create_options ( create_options &&  opts)
inline

Move constructor.

Parameters
optsThe 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
serverURIThe URI of the server.

◆ get_server_uri()

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

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
clientIdThe client identifier.

◆ get_client_id()

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

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
persistenceThe persistence for the client

◆ get_persistence()

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

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
ontrue to allow the application to publish messages while disconnected, false returns an error on publish if disconnected.
anyTimeIf 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
nThe 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
verThe 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
ontrue 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
ontrue 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
ontrue 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: