aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
|
#include <MqttClient.h>
Public Member Functions | |
~MqttConnection () | |
MqttConnection (const MqttConnection &)=delete | |
MqttConnection (MqttConnection &&)=delete | |
MqttConnection & | operator= (const MqttConnection &)=delete |
MqttConnection & | operator= (MqttConnection &&)=delete |
operator bool () const noexcept | |
int | LastError () const noexcept |
bool | SetWill (const char *topic, QOS qos, bool retain, const ByteBuf &payload) noexcept |
bool | SetLogin (const char *userName, const char *password) noexcept |
bool | SetWebsocketProxyOptions (const Http::HttpClientConnectionProxyOptions &proxyOptions) noexcept |
bool | SetHttpProxyOptions (const Http::HttpClientConnectionProxyOptions &proxyOptions) noexcept |
bool | SetReconnectTimeout (uint64_t min_seconds, uint64_t max_seconds) noexcept |
bool | Connect (const char *clientId, bool cleanSession, uint16_t keepAliveTimeSecs=0, uint32_t pingTimeoutMs=0, uint32_t protocolOperationTimeoutMs=0) noexcept |
bool | Disconnect () noexcept |
uint16_t | Subscribe (const char *topicFilter, QOS qos, OnMessageReceivedHandler &&onMessage, OnSubAckHandler &&onSubAck) noexcept |
uint16_t | Subscribe (const char *topicFilter, QOS qos, OnPublishReceivedHandler &&onPublish, OnSubAckHandler &&onSubAck) noexcept |
uint16_t | Subscribe (const Vector< std::pair< const char *, OnMessageReceivedHandler > > &topicFilters, QOS qos, OnMultiSubAckHandler &&onOpComplete) noexcept |
uint16_t | Subscribe (const Vector< std::pair< const char *, OnPublishReceivedHandler > > &topicFilters, QOS qos, OnMultiSubAckHandler &&onOpComplete) noexcept |
bool | SetOnMessageHandler (OnMessageReceivedHandler &&onMessage) noexcept |
bool | SetOnMessageHandler (OnPublishReceivedHandler &&onPublish) noexcept |
uint16_t | Unsubscribe (const char *topicFilter, OnOperationCompleteHandler &&onOpComplete) noexcept |
uint16_t | Publish (const char *topic, QOS qos, bool retain, const ByteBuf &payload, OnOperationCompleteHandler &&onOpComplete) noexcept |
Friends | |
class | MqttClient |
Represents a persistent Mqtt Connection. The memory is owned by MqttClient. To get a new instance of this class, see MqttClient::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 |
|
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 |
OnConnectionCompletedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionCompleted |
OnConnectionInterruptedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionInterrupted |
OnConnectionResumedHandler Aws::Crt::Mqtt::MqttConnection::OnConnectionResumed |
OnDisconnectHandler Aws::Crt::Mqtt::MqttConnection::OnDisconnect |
OnWebSocketHandshakeIntercept Aws::Crt::Mqtt::MqttConnection::WebsocketInterceptor |