PrevUpHomeNext

LoggerType concept

LoggerType represents an object type that will be used by the mqtt_client to log events.

A type satisfies the LoggerType concept if it defines any number (including zero) of the following functions:

Function signature

Arguments

Description

void at_resolve(error_code ec, std::string_view host, std::string_view port, const asio::ip::tcp::resolver::results_type& eps);

ec is the error_code returned by the resolve operation.

host is the hostname used in the resolve.

port is the port used in the resolve.

eps is a list of endpoints returned by the resolve operation.

Invoked when the resolve operation is complete.

void at_tcp_connect(error_code ec, asio::ip::tcp::endpoint ep);

ec is the error_code returned by the TCP connect operation.

ep is a TCP endpoint used to establish the TCP connection.

Invoked when the TCP connect operation is complete.

void at_tls_handshake(error_code ec, asio::ip::tcp::endpoint ep);

ec is the error_code returned by the the TLS handshake operation.

ep is a TCP endpoint used to establish the TLS handshake.

Invoked when the TLS handshake operation is complete.

void at_ws_handshake(error_code ec, asio::ip::tcp::endpoint ep);

ec is the error_code returned by the the WebSocket handshake operation.

ep is a TCP endpoint used to establish the WebSocket handshake.

Invoked when the WebSocket handshake operation is complete.

void at_connack(reason_code rc, bool session_present, const connack_props& ca_props);

rc is the reason_code received in the CONNACK packet indicating the result of the MQTT handshake.

session_present A flag indicating whether the Broker already has a session associated with this connection.

ca_props async_mqtt5::connack_props received in the CONNACK packet.

Invoked when the CONNACK packet is received, marking the completion of the MQTT handshake.

void at_disconnect(reason_code rc, const disconnect_props& dc_props);

rc is the reason_code received in the DISCONNECT packet specifying the reason behind the disconnection.

dc_props async_mqtt5::disconnect_props received in the DISCONNECT packet.

Invoked when the DISCONNECT packet is received, indicating that the Broker wants to close this connection.

For example, a type T that defines at_connack and at_disconnect functions with their respective arguments is considered a valid LoggerType. This allows you to create your own LoggerType classes with functions of interest.

All defined functions are invoked directly within the mqtt_client using its default executor. If the mqtt_client is initialized with an explicit or implicit strand, none of the functions will be invoked concurrently.

[Warning] Warning

Defined functions should not block and stop the mqtt_client from doing work.

A class that satifies this concept is logger.


PrevUpHomeNext