24 #ifndef __mqtt_connect_options_h
25 #define __mqtt_connect_options_h
27 #include "MQTTAsync.h"
49 static const MQTTAsync_connectOptions DFLT_C_STRUCT ;
52 MQTTAsync_connectOptions opts_;
70 const_string_collection_ptr serverURIs_;
74 friend class connect_options_test;
75 friend class token_test;
93 using ptr_t = std::shared_ptr<connect_options>;
132 return std::chrono::seconds(opts_.keepAliveInterval);
141 return std::chrono::seconds(opts_.connectTimeout);
158 return password_ ? password_.
to_string() : string();
215 const_string_collection_ptr
get_servers()
const {
return serverURIs_; }
238 return std::chrono::seconds(opts_.minRetryInterval);
246 return std::chrono::seconds(opts_.maxRetryInterval);
255 opts_.cleansession = to_int(cleanSession);
262 opts_.connectTimeout = timeout;
272 opts_.keepAliveInterval = keepAliveInterval;
281 template <
class Rep,
class Period>
293 opts_.connectTimeout = to;
301 template <
class Rep,
class Period>
339 void set_servers(const_string_collection_ptr serverURIs);
355 opts_.automaticReconnect = on ? !0 : 0;
372 template <
class Rep1,
class Period1,
class Rep2,
class Period2>
374 const std::chrono::duration<Rep2, Period2>& maxRetryInterval) {
376 (
int) to_seconds_count(maxRetryInterval));
392 #endif // __mqtt_connect_options_h
Lightweight client for talking to an MQTT server using non-blocking methods that allow an operation t...
Definition: async_client.h:60
std::shared_ptr< connect_options > ptr_t
Smart/shared pointer to an object of this class.
Definition: connect_options.h:93
void set_clean_session(bool cleanSession)
Sets whether the server should remember state for the client across reconnects.
Definition: connect_options.h:254
Basic types and type conversions for the Paho MQTT C++ library.
string get_will_topic() const
Gets the topic to be used for last will and testament (LWT).
Definition: connect_options.h:170
string get_password_str() const
Gets the password to use for the connection.
Definition: connect_options.h:157
void set_max_inflight(int n)
Sets the maximum number of messages that can be in-flight simultaneously.
Definition: connect_options.h:320
const_message_ptr get_message() const
Gets the LWT message as a message object.
Definition: will_options.h:193
int get_max_inflight() const
Gets the maximum number of messages that can be in-flight simultaneously.
Definition: connect_options.h:165
Holds the set of SSL options for connection.
Definition: ssl_options.h:41
Declaration of MQTT will_options class.
void set_password(binary_ref password)
Sets the password to use for the connection.
connect_options()
Constructs a new object using the default values.
void set_keep_alive_interval(int keepAliveInterval)
Sets the "keep alive" interval.
Definition: connect_options.h:271
std::shared_ptr< const connect_options > const_ptr_t
Smart/shared pointer to a const object of this class.
Definition: connect_options.h:95
const_message_ptr get_will_message() const
Gets the message to be sent as last will and testament (LWT).
Definition: connect_options.h:177
Definition of the string_collection class for the Paho MQTT C++ library.
Holds the set of options that control how the client connects to a server.
Definition: connect_options.h:46
const char * c_str() const
Gets the data buffer as NUL-terminated C string.
Definition: buffer_ref.h:257
connect_options & operator=(const connect_options &opt)
Copy assignment.
bool is_clean_session() const
Returns whether the server should remember state for the client across reconnects.
Definition: connect_options.h:202
void set_servers(const_string_collection_ptr serverURIs)
Sets the list of servers to which the client will connect.
Declaration of MQTT message class.
std::chrono::seconds get_max_retry_interval() const
Gets the maximum retry interval for automatic reconnect.
Definition: connect_options.h:245
void set_connection_timeout(int timeout)
Sets the connection timeout value.
Definition: connect_options.h:261
bool get_automatic_reconnect() const
Determines if the options have been configured for automatic reconnect.
Definition: connect_options.h:231
void set_token(const token_ptr &tok)
Sets the callback context to a delivery token.
std::chrono::seconds get_min_retry_interval() const
Gets the minimum retry interval for automatic reconnect.
Definition: connect_options.h:237
void set_mqtt_version(int mqttVersion)
Sets the version of MQTT to be used on the connect.
Definition: connect_options.h:348
void set_automatic_reconnect(const std::chrono::duration< Rep1, Period1 > &minRetryInterval, const std::chrono::duration< Rep2, Period2 > &maxRetryInterval)
Enable or disable automatic reconnects.
Definition: connect_options.h:373
void set_ssl(const ssl_options &ssl)
Sets the SSL for the connection.
string to_string() const
Gets a string representation of the object.
string get_user_name() const
Gets the user name to use for the connection.
Definition: connect_options.h:147
void set_automatic_reconnect(bool on)
Enable or disable automatic reconnects.
Definition: connect_options.h:354
bool empty() const
Determines if the buffer is empty.
Definition: buffer_ref.h:226
token_ptr get_token() const
Gets the token used as the callback context.
Definition: connect_options.h:207
void set_will(const will_options &will)
Sets the "Last Will and Testament" (LWT) for the connection.
int get_mqtt_version() const
Gets the version of MQTT to be used on the connect.
Definition: connect_options.h:224
void set_user_name(string_ref userName)
Sets the user name to use for the connection.
binary_ref get_password() const
Gets the password to use for the connection.
Definition: connect_options.h:152
string get_topic() const
Gets the LWT message topic name.
Definition: will_options.h:168
void set_connect_timeout(int to)
Sets the connect timeout in seconds.
Definition: connect_options.h:292
std::chrono::seconds get_connect_timeout() const
Gets the connection timeout.
Definition: connect_options.h:140
void set_keep_alive_interval(const std::chrono::duration< Rep, Period > &interval)
Sets the "keep alive" interval with a chrono duration.
Definition: connect_options.h:282
Declaration of MQTT topic class.
const ssl_options & get_ssl_options() const
Get the SSL options to use for the connection.
Definition: connect_options.h:189
std::chrono::seconds get_keep_alive_interval() const
Gets the "keep alive" interval.
Definition: connect_options.h:131
const will_options & get_will_options() const
Get the LWT options to use for the connection.
Definition: connect_options.h:184
Holds the set of options that govern the Last Will and Testament feature.
Definition: will_options.h:47
Declaration of MQTT ssl_options class.
const_string_collection_ptr get_servers() const
Gets the list of servers to which the client will connect.
Definition: connect_options.h:215
Declaration of MQTT token class.
void set_connect_timeout(const std::chrono::duration< Rep, Period > &to)
Sets the connect timeout with a chrono duration.
Definition: connect_options.h:302
const blob & to_string() const
Gets the data buffer as a string.
Definition: buffer_ref.h:251