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

`#include <connect_options.h>`

## Public Types

using | self = connect_options_builder

## Public Member Functions

| connect_options_builder (int ver=MQTTVERSION_DEFAULT)
| connect_options_builder (const connect_options &opts)
| connect_options_builder (const connect_options &&opts)
auto | clean_session (bool on=true) -> self &
template<class Rep , class Period >
auto | keep_alive_interval (const std::chrono::duration< Rep, Period > &interval) -> self &
template<class Rep , class Period >
auto | connect_timeout (const std::chrono::duration< Rep, Period > &timeout) -> self &
auto | user_name (string_ref userName) -> self &
auto | password (binary_ref password) -> self &
auto | max_inflight (int n) -> self &
auto | will (const will_options &will) -> self &
auto | will (will_options &&will) -> self &
auto | will (const message &msg) -> self &
auto | ssl (const ssl_options &ssl) -> self &
auto | ssl (ssl_options &&ssl) -> self &
auto | token (const token_ptr &tok) -> self &
auto | servers (const_string_collection_ptr serverURIs) -> self &
auto | mqtt_version (int ver) -> self &
auto | automatic_reconnect (bool on=true) -> self &
template<class Rep1 , class Period1 , class Rep2 , class Period2 >
auto | automatic_reconnect (const std::chrono::duration< Rep1, Period1 > &minRetryInterval, const std::chrono::duration< Rep2, Period2 > &maxRetryInterval) -> self &
auto | clean_start (bool on=true) -> self &
auto | properties (const mqtt::properties &props) -> self &
auto | properties (mqtt::properties &&props) -> self &
auto | http_headers (const name_value_collection &headers) -> self &
auto | http_headers (name_value_collection &&headers) -> self &
auto | http_proxy (const string &httpProxy) -> self &
auto | https_proxy (const string &httpsProxy) -> self &
connect_options | finalize ()

## Static Public Member Functions

static connect_options_builder | v3 ()
static connect_options_builder | v5 ()
static connect_options_builder | ws ()
static connect_options_builder | v5_ws ()

## Detailed Description

Class to build connect options.

## Member Typedef Documentation

## self

using mqtt::connect_options_builder::self = connect_options_builder

This class

## Constructor & Destructor Documentation

## connect_options_builder() [1/3]

mqtt::connect_options_builder::connect_options_builder | ( | int | ver = `MQTTVERSION_DEFAULT` | ) |

inline explicit

Default constructor.

Parameters

  ver | The MQTT version for the connection. Defaults to the most recent v3 supported by the server.

## connect_options_builder() [2/3]

mqtt::connect_options_builder::connect_options_builder | ( | const connect_options & | opts | ) |

inline explicit

Copy constructor from an existing set of options.

## connect_options_builder() [3/3]

mqtt::connect_options_builder::connect_options_builder | ( | const connect_options && | opts | ) |

inline explicit

Move constructor from an existing set of options.

## Member Function Documentation

## v3()

static connect_options_builder mqtt::connect_options_builder::v3 | ( |  | ) |

inline static

Creates the default options builder for an MQTT v3.x connection.

Returns
  An options builder for an MQTT v3.x connection.

## v5()

static connect_options_builder mqtt::connect_options_builder::v5 | ( |  | ) |

inline static

Creates the default options builder for an MQTT v5 connection.

Returns
  An options builder for an MQTT v5 connection.

## ws()

static connect_options_builder mqtt::connect_options_builder::ws | ( |  | ) |

inline static

Creates the default options builder for an MQTT v3.x connection using WebSockets.

The keepalive interval is set to 45 seconds to avoid webserver 60 second inactivity timeouts.

Returns
  An options builder for an MQTT v3.x connection using websockets.

## v5_ws()

static connect_options_builder mqtt::connect_options_builder::v5_ws | ( |  | ) |

inline static

Creates the default options for an MQTT v5 connection using WebSocketsThe keepalive interval is set to 45 seconds to avoid webserver 60 second inactivity timeouts.

Returns
  An options builder for an MQTT v5 connection using websockets.

## clean_session()

auto mqtt::connect_options_builder::clean_session | ( | bool | on = `true` | ) | -> self&

inline

Sets whether the server should remember state for the client across reconnects. (MQTT v3.x only)

Parameters

  on | true if the server should NOT remember state for the client across reconnects, false otherwise.

## keep_alive_interval()

template<class Rep , class Period >

auto mqtt::connect_options_builder::keep_alive_interval | ( | const std::chrono::duration< Rep, Period > & | interval | ) | -> self&

inline

Sets the "keep alive" interval with a chrono duration. This is the maximum time that should pass without communications between client and server. If no messages pass in this time, the client will ping the broker.

Parameters

  interval | The keep alive interval.

## connect_timeout()

template<class Rep , class Period >

auto mqtt::connect_options_builder::connect_timeout | ( | const std::chrono::duration< Rep, Period > & | timeout | ) | -> self&

inline

Sets the connect timeout with a chrono duration. This is the maximum time that the underlying library will wait for a connection before failing.

Parameters

  timeout | The connect timeout in seconds.

## user_name()

auto mqtt::connect_options_builder::user_name | ( | string_ref | userName | ) | -> self&

inline

Sets the user name for the connection.

Parameters

  userName | The user name for the connection.

## password()

auto mqtt::connect_options_builder::password | ( | binary_ref | password | ) | -> self&

inline

Sets the password for the connection.

Parameters

  password | The password for the connection.

## max_inflight()

auto mqtt::connect_options_builder::max_inflight | ( | int | n | ) | -> self&

inline

Sets the maximum number of messages that can be in-flight simultaneously.

Parameters

  n | The maximum number of inflight messages.

## will() [1/3]

auto mqtt::connect_options_builder::will | ( | const will_options & | will | ) | -> self&

inline

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  will | The LWT options.

## will() [2/3]

auto mqtt::connect_options_builder::will | ( | will_options && | will | ) | -> self&

inline

Sets the "Last Will and Testament" (LWT) for the connection.

Parameters

  will | The LWT options.

## will() [3/3]

auto mqtt::connect_options_builder::will | ( | const message & | msg | ) | -> self&

inline

Sets the "Last Will and Testament" (LWT) as a message

Parameters

  msg | The LWT message

## ssl() [1/2]

auto mqtt::connect_options_builder::ssl | ( | const ssl_options & | ssl | ) | -> self&

inline

Sets the SSL options for the connection. These will only have an effect if compiled against the SSL version of the Paho C library, and connecting with a secure URI.

Parameters

  ssl | The SSL options.

## ssl() [2/2]

auto mqtt::connect_options_builder::ssl | ( | ssl_options && | ssl | ) | -> self&

inline

Sets the SSL options for the connection. These will only have an effect if compiled against the SSL version of the Paho C library, and connecting with a secure URI.

Parameters

  ssl | The SSL options.

## token()

auto mqtt::connect_options_builder::token | ( | const token_ptr & | tok | ) | -> self&

inline

Sets the callback context to a delivery token.

Parameters

  tok | The delivery token to be used as the callback context.

## servers()

auto mqtt::connect_options_builder::servers | ( | const_string_collection_ptr | serverURIs | ) | -> self&

inline

Sets the list of servers to which the client will connect.

Parameters

  serverURIs | A pointer to a collection of server URI's. Each entry should be of the form protocol://host:port where protocol must be tcp or ssl. For host, you can specify either an IP address or a domain name.

## mqtt_version()

auto mqtt::connect_options_builder::mqtt_version | ( | int | ver | ) | -> self&

inline

Sets the version of MQTT to be used on the connect.

This will also set other connect options to legal values dependent on the selected version.

Parameters

  ver

  The MQTT protocol version to use for the connection:
  - MQTTVERSION_DEFAULT (0) = default: start with 3.1.1, and if that fails, fall back to 3.1
  - MQTTVERSION_3_1 (3) = only try version 3.1
  - MQTTVERSION_3_1_1 (4) = only try version 3.1.1
  - MQTTVERSION_5 (5) = only try version 5
  Note that it is preferable to create the options builder for the desired version rather than using this function to change the version after some parameters have already been set. If you do use this function, call it before setting any other version-specific options.

See also
  connect_options_builder::v5()

## automatic_reconnect() [1/2]

auto mqtt::connect_options_builder::automatic_reconnect | ( | bool | on = `true` | ) | -> self&

inline

Enable or disable automatic reconnects. The retry intervals are not affected.

Parameters

  on | Whether to turn reconnects on or off

## automatic_reconnect() [2/2]

template<class Rep1 , class Period1 , class Rep2 , class Period2 >

auto mqtt::connect_options_builder::automatic_reconnect | ( | const std::chrono::duration< Rep1, Period1 > & | minRetryInterval,
|  | const std::chrono::duration< Rep2, Period2 > & | maxRetryInterval
| ) |  | -> self&

inline

Enable or disable automatic reconnects.

Parameters

  minRetryInterval | Minimum retry interval. Doubled on each failed retry.
  maxRetryInterval | Maximum retry interval. The doubling stops here on failed retries.

## clean_start()

auto mqtt::connect_options_builder::clean_start | ( | bool | on = `true` | ) | -> self&

inline

Sets the 'clean start' flag for the connection. (MQTT v5 only)

Parameters

  on | true to set the 'clean start' flag for the connect, false otherwise.

## properties() [1/2]

auto mqtt::connect_options_builder::properties | ( | const mqtt::properties & | props | ) | -> self&

inline

Sets the properties for the connect message.

Parameters

  props | The properties for the connect message.

## properties() [2/2]

auto mqtt::connect_options_builder::properties | ( | mqtt::properties && | props | ) | -> self&

inline

Sets the properties for the connect message.

Parameters

  props | The properties for the connect message.

## http_headers() [1/2]

auto mqtt::connect_options_builder::http_headers | ( | const name_value_collection & | headers | ) | -> self&

inline

Sets the HTTP headers for the connection.

Parameters

  headers | The header nam/value collection.

## http_headers() [2/2]

auto mqtt::connect_options_builder::http_headers | ( | name_value_collection && | headers | ) | -> self&

inline

Sets the HTTP headers for the connection.

Parameters

  headers | The header nam/value collection.

## http_proxy()

auto mqtt::connect_options_builder::http_proxy | ( | const string & | httpProxy | ) | -> self&

inline

Sets the HTTP proxy setting.

Parameters

  httpProxy | The HTTP proxy setting. An empty string means no proxy.

## https_proxy()

auto mqtt::connect_options_builder::https_proxy | ( | const string & | httpsProxy | ) | -> self&

inline

Sets the secure HTTPS proxy setting.

Parameters

  httpsProxy | The HTTPS proxy setting. An empty string means no proxy.

## finalize()

connect_options mqtt::connect_options_builder::finalize | ( |  | ) |

inline

Finish building the options and return them.

Returns
  The option struct as built.

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

- connect_options.h