![]() |
PahoMqttCpp
MQTT C++ Client for POSIX and Windows
|
#include <event.h>
Public Types | |
using | event_type = std::variant< const_message_ptr, connected_event, connection_lost_event, disconnected_event, shutdown_event > |
Public Member Functions | |
event () | |
event (event_type evt) | |
event (message_ptr msg) | |
event (const_message_ptr msg) | |
event (connected_event evt) | |
event (connection_lost_event evt) | |
event (disconnected_event evt) | |
event (shutdown_event evt) | |
event (const event &evt) | |
event (event &&evt) | |
event & | operator= (event_type evt) |
event & | operator= (const event &rhs) |
event & | operator= (event &&rhs) |
bool | is_message () const |
bool | is_connected () const |
bool | is_connection_lost () const |
bool | is_disconnected () const |
bool | is_shutdown () const |
bool | is_any_disconnect () const |
const_message_ptr | get_message () |
disconnected_event | get_disconnected () |
constexpr std::add_pointer_t< const_message_ptr > | get_message_if () noexcept |
constexpr std::add_pointer_t< disconnected_event > | get_disconnected_if () noexcept |
An MQTT event.
This is used by the client consumer to pass events and state changes from the client to the application without the need for any additional callbacks or client queries.
Each instance carries the relevant data for specific event that caused it. For example an incoming message event contains a shared pointer to the message that arrived.
The supported event types are:
using mqtt::event::event_type = std::variant< const_message_ptr, connected_event, connection_lost_event, disconnected_event, shutdown_event> |
The variant type for any possible event.
|
inline |
Constructs an empty event. This shows as a message, but the message pointer is null.
|
inline |
Constructs an event from an event type variant.
evt | The event type variant. |
|
inline |
Constructs a message event.
msg | A shared message pointer. |
|
inline |
Constructs a message event.
msg | A shared const message pointer. |
|
inline |
Constructs a 'connected' event.
evt | A connected event. |
|
inline |
Constructs a 'connection lost' event.
evt | A connection lost event. |
|
inline |
Constructs a 'disconnected' event.
evt | A disconnected event. |
|
inline |
Constructs a 'shutdown' event.
evt | A shutdown event. |
|
inline |
Copy constructor.
evt | The event to copy. |
|
inline |
Move constructor.
evt | The event to move. |
|
inline |
Assignment from an event type variant.
evt | The event type variant. |
Copy assignment.
rhs | The event to copy. |
Move assignment.
rhs | The event to move. |
|
inline |
Determines if this event is an incoming message.
|
inline |
Determines if this event is a client (re)connection.
|
inline |
Determines if this event is a client connection lost.
|
inline |
Determines if this event is a client disconnected.
|
inline |
Determines if this event is an internal shutdown request.
|
inline |
Determines if this is any type of client disconnect or shutdown.
|
inline |
Gets the message from the event, iff this is a message event.
std::bad_variant_access | if this is not a 'message' event. |
|
inline |
Gets the underlying information for a disconnected event iff this is a 'disconnected' event. This contains the reason code and properties that the server sent in the DISCONNECT packet.
std::bad_variant_access | if this is not a 'disconnected' event. |
|
inlineconstexprnoexcept |
Gets a pointer to the message in the event, iff this is a message event.
|
inlineconstexprnoexcept |
Gets a pointer the underlying information for a disconnected event, iff this is a 'disconnected' event. This contains the reason code and properties that the server sent in the DISCONNECT packet.
std::bad_variant_access | if this is not a 'disconnected' event. |