aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
|
#include <MqttConnection.h>
Static Public Member Functions | |
static std::shared_ptr< Crt::Mqtt::MqttConnection > | NewConnectionFromMqtt5Client (std::shared_ptr< Mqtt5::Mqtt5Client > mqtt5client) noexcept |
Friends | |
class | MqttClient |
class | Mqtt5::Mqtt5ClientCore |
Represents a persistent Mqtt Connection. The memory is owned by MqttClient or Mqtt5Client.
To get a new instance of this class, use MqttClient::NewConnection or Mqtt5Client::NewConnection. Unless specified all function arguments need only to live through the duration of the function call.
Aws::Crt::Mqtt::MqttConnection::~MqttConnection | ( | ) |
|
delete |
|
delete |
|
noexcept |
Initiates the connection, OnConnectionCompleted will be invoked in an event-loop thread.
clientId | client identifier to use when establishing the mqtt connection |
cleanSession | false to attempt to rejoin an existing session for the client id, true to skip and start with a new session |
keepAliveTimeSecs | time interval to space mqtt pings apart by |
pingTimeoutMs | timeout in milliseconds before the keep alive ping is considered to have failed |
protocolOperationTimeoutMs | timeout in milliseconds to give up waiting for a response packet for an operation. Necessary due to throttling properties on certain server implementations that do not return an ACK for throttled operations. |
|
noexcept |
Initiates disconnect, OnDisconnectHandler will be invoked in an event-loop thread.
|
noexcept |
Get the statistics about the current state of the connection's queue of operations
|
noexcept |
|
staticnoexcept |
Create a new MqttConnection object from the Mqtt5Client.
mqtt5client | The shared ptr of Mqtt5Client |
As we passed the std::shared_ptr<Mqtt5Client> by value, this function scope would keep a reference of the Mqtt5Client thus the underlying c client. Therefore we directly access the c client here. Other than that, we should never directly access the underlying c client without acquire the reference.
|
noexcept |
|
delete |
|
delete |
|
noexcept |
Publishes to a topic.
topic | topic to publish to |
qos | QOS to publish the message with |
retain | should this message replace the current retained message of the topic? |
payload | payload of the message |
onOpComplete | completion callback to invoke when the operation is complete. If QoS is 0, then the callback is invoked when the message is passed to the tls handler, otherwise it's invoked on receipt of the final response from the server. |
|
noexcept |
Sets http proxy options. In order to use an http proxy with mqtt either (1) Websockets are used (2) Mqtt-over-tls is used and the ALPN list of the tls context contains a tag that resolves to mqtt
proxyOptions | proxy configuration for making the mqtt connection |
|
noexcept |
Sets login credentials for the connection. The must get set before the Connect call if it is to be used.
username | user name to add to the MQTT CONNECT packet |
password | password to add to the MQTT CONNECT packet |
|
noexcept |
Installs a handler for all incoming publish messages, regardless of if Subscribe has been called on the topic.
onMessage | callback to invoke for all received messages |
|
noexcept |
|
noexcept |
Customize time to wait between reconnect attempts. The time will start at min and multiply by 2 until max is reached. The time resets back to min after a successful connection. This function should only be called before Connect().
min_seconds | minimum time to wait before attempting a reconnect |
max_seconds | maximum time to wait before attempting a reconnect |
|
noexcept |
|
noexcept |
Sets LastWill for the connection.
topic | topic the will message should be published to |
qos | QOS the will message should be published with |
retain | true if the will publish should be treated as a retained publish |
payload | payload of the will message |
|
noexcept |
Subscribes to topicFilter. OnMessageReceivedHandler will be invoked from an event-loop thread upon an incoming Publish message. OnSubAckHandler will be invoked upon receipt of a suback message.
topicFilter | topic filter to subscribe to |
qos | maximum qos client is willing to receive matching messages on |
onMessage | callback to invoke when a message is received based on matching this filter |
onSubAck | callback to invoke with the server's response to the subscribe request |
|
noexcept |
|
noexcept |
Subscribes to multiple topicFilters. OnMessageReceivedHandler will be invoked from an event-loop thread upon an incoming Publish message. OnMultiSubAckHandler will be invoked upon receipt of a suback message.
topicFilters | list of pairs of topic filters and message callbacks to invoke on a matching publish |
qos | maximum qos client is willing to receive matching messages on |
onOpComplete | callback to invoke with the server's response to the subscribe request |
|
noexcept |
|
noexcept |
Unsubscribes from topicFilter. OnOperationCompleteHandler will be invoked upon receipt of an unsuback message.
topicFilter | topic filter to unsubscribe the session from |
onOpComplete | callback to invoke on receipt of the server's UNSUBACK message |
|
friend |
OnConnectionClosedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionClosed |
Invoked when a connection is disconnected and shutdown successfully.
OnConnectionCompletedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionCompleted |
Invoked when a connack message is received, or an error occurred.
OnConnectionFailureHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionFailure |
Invoked whenever the connection fails to connect.
This callback is invoked for every failed connect and every failed reconnect.
OnConnectionInterruptedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionInterrupted |
A callback invoked every time the connections is interrupted.
OnConnectionResumedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionResumed |
A callback invoked every time the connection is resumed.
OnConnectionSuccessHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionSuccess |
Invoked whenever the connection successfully connects.
This callback is invoked for every successful connect and every successful reconnect.
OnDisconnectHandler Aws::Crt::Mqtt::MqttConnection::OnDisconnect |
A callback invoked on disconnect.
OnWebSocketHandshakeIntercept Aws::Crt::Mqtt::MqttConnection::WebsocketInterceptor |
Invoked during websocket handshake to give users opportunity to transform an http request for purposes such as signing/authorization etc... Returning from this function does not continue the websocket handshake since some work flows may be asynchronous. To accommodate that, onComplete must be invoked upon completion of the signing process.