13#ifndef MQTT_CLIENT_HPP
14#define MQTT_CLIENT_HPP
27#include "uic_version.h"
56 const std::string &client_id,
57 const std::string &cafile,
58 const std::string &certfile,
59 const std::string &keyfile,
72 void event(
const int incoming_event);
73 std::function<int(
const int,
void *)>
76 std::function<int(
const int,
void *)>
81 const std::string &message,
82 size_t message_length,
91 void unretain(
const std::string &prefix_pattern);
126 const std::string &message,
127 size_t message_length,
129 bool message_retain);
181 std::chrono::milliseconds delay_time);
Definition: mqtt_client_fsm.hpp:59
Definition: mqtt_client_fsm.hpp:44
Definition: mqtt_client_fsm.hpp:29
Definition: mqtt_client_fsm.hpp:20
void(* message_callback_ex_t)(const char *topic, const char *message, const size_t message_length, void *user)
A callback type for pushing incoming messages.
Definition: mqtt_client.h:118
void(* mqtt_connection_callback_t)(mqtt_client_t instance, const int file_descriptor)
A callback type for MQTT connection/disconnection events.
Definition: mqtt_client.h:128
void(* mqtt_simple_callback_t)()
A void function type (void function()) to invoke when some events occurred.
Definition: mqtt_client.h:134
uint32_t sl_status_t
Definition: sl_status.h:139
Definition: mqtt_client.hpp:34
std::string message
Definition: mqtt_client.hpp:36
bool retain
Definition: mqtt_client.hpp:38
size_t message_length
Definition: mqtt_client.hpp:37
std::string topic
Definition: mqtt_client.hpp:35
Definition: mqtt_client.hpp:43
bool operator==(const callback_info &rhs) const
Definition: mqtt_client.hpp:47
void * user
Definition: mqtt_client.hpp:45
message_callback_ex_t callback
Definition: mqtt_client.hpp:44
Definition: mqtt_client.hpp:41
const char * get_client_id() const
void unretain_by_regex(const std::string ®ex)
Un-retain previously retained messages.
void before_disconnect_callback_call()
std::set< std::string > retained_topics
Definition: mqtt_client.hpp:156
void event(const int incoming_event)
std::string mqtt_cafile
Definition: mqtt_client.hpp:169
void * mqtt_client_library_instance
Definition: mqtt_client.hpp:167
bool connected_to_broker
Definition: mqtt_client.hpp:172
std::map< std::string, std::vector< callback_info > > subscription_callbacks
Definition: mqtt_client.hpp:155
void subscribe(const std::string &topic, const callback_info &callback)
int socket_file_descriptor
Definition: mqtt_client.hpp:142
void after_connect_callback_set(mqtt_simple_callback_t)
void publish(const std::string &topic, const std::string &message, size_t message_length, bool retain)
std::string mqtt_client_id
Definition: mqtt_client.hpp:168
std::set< mqtt_connection_callback_t > on_connect_callbacks
Definition: mqtt_client.hpp:145
std::string mqtt_keyfile
Definition: mqtt_client.hpp:171
void unsubscribe(const std::string &topic, const callback_info &callback)
std::function< int(const int, void *)> event_counter
Definition: mqtt_client.hpp:77
void on_connect_callback_set(mqtt_connection_callback_t)
std::deque< message_queue_element_t > publishing_queue
Definition: mqtt_client.hpp:152
int count_topics(const std::string &prefix_pattern)
Count the number of topics published.
mqtt_client(const std::string &hostname, const uint32_t port, const std::string &client_id, const std::string &cafile, const std::string &certfile, const std::string &keyfile, std::function< int(const int, void *)> event_sender, std::function< void(const int, const unsigned long)> delayed_event_sender, std::function< int(const int, void *)> event_counter)
bool unsubscription_messages_waiting()
std::function< void(const int, const unsigned long)> delayed_event_sender
Definition: mqtt_client.hpp:75
void before_disconnect_callback_set(mqtt_simple_callback_t)
std::chrono::milliseconds next_reconnect_backoff
Definition: mqtt_client.hpp:143
std::string mqtt_certfile
Definition: mqtt_client.hpp:170
void transition(mqtt_client_fsm &new_state)
void on_message(const std::string &topic, const std::string &message, size_t message_length, int message_qos, bool message_retain)
void send_delayed_event(const int outgoing_event, std::chrono::milliseconds delay_time)
sl_status_t publish_to_broker(bool flushing=false)
const uint32_t port
Definition: mqtt_client.hpp:141
bool subscription_messages_waiting()
void unretain(const std::string &prefix_pattern)
Un-retain previously retained messages.
std::function< int(const int, void *)> event_sender
Definition: mqtt_client.hpp:74
std::set< mqtt_simple_callback_t > before_disconnect_callbacks
Definition: mqtt_client.hpp:147
std::set< mqtt_simple_callback_t > after_connect_callbacks
Definition: mqtt_client.hpp:148
void after_connect_callback_call()
void on_connect(int return_code)
void on_disconnect(int return_code)
void on_disconnect_callback_set(mqtt_connection_callback_t)
std::set< mqtt_connection_callback_t > on_disconnect_callbacks
Definition: mqtt_client.hpp:146
std::chrono::milliseconds max_reconnect_backoff
Definition: mqtt_client.hpp:144
void send_event(const int outgoing_event, void *procdata)
sl_status_t unsubscribe_from_topic()
sl_status_t subscribe_to_topic()
std::queue< std::string > unsubscription_queue
Definition: mqtt_client.hpp:154
std::queue< std::string > subscription_queue
Definition: mqtt_client.hpp:153
mqtt_client_fsm * current_state
Definition: mqtt_client.hpp:178
bool publish_messages_waiting()
bool is_connected_to_broker() const
const std::string hostname
Definition: mqtt_client.hpp:140