We’re integrating boost::mqtt5::mqtt_client and need a reliable way to react to connection lifecycle transitions (e.g., set internal “connected/offline” state, emit telemetry, detect misconfiguration).
From the docs:
- mqtt_client doesn’t expose connect/async_connect; async_run starts the connection attempt(s).
- The auto-reconnect design can hide persistent misconfiguration, and the docs suggest using the logging mechanism to detect those cases.
We also see mqtt_client has a LoggerType template parameter, and the LoggerType concept allows implementing any subset of callbacks such as:
at_resolve, at_tcp_connect, at_tls_handshake, at_ws_handshake, at_transport_error, at_connack, at_disconnect, at_ws_handshake.
Questions:
- Is supplying a custom LoggerType the intended/official extension point to observe these lifecycle events (beyond printing debug output)?
- If yes, is it considered acceptable to use LoggerType callbacks for application state (e.g., raising events/flags), or is LoggerType meant strictly for diagnostics?
- If no, is there another recommended pattern/API for “connected / reconnecting / disconnected” signals (or would you consider adding one)?
Implementation-wise, our plan is to provide a LoggerType that forwards at_* calls to std::function callbacks (so we can hook at_connack/at_disconnect/etc.). Does that align with the library’s intended paradigm?