AWS IoT Device SDK C++ v2: Aws::Crt::Mqtt::MqttClient Class Reference

AWS IoT Device SDK C++ v2 1.14.0 AWS IoT Device SDK C++ v2

Public Member Functions | List of all members
Aws::Crt::Mqtt::MqttClient Class Referencefinal

`#include <MqttClient.h>`

## Public Member Functions
| MqttClient (Io::ClientBootstrap &bootstrap, Allocator *allocator=g_allocator) noexcept
| ~MqttClient ()
| MqttClient (const MqttClient &)=delete
| MqttClient (MqttClient &&) noexcept
MqttClient & | operator= (const MqttClient &)=delete
MqttClient & | operator= (MqttClient &&) noexcept
| operator bool () const noexcept
int | LastError () const noexcept
std::shared_ptr< MqttConnection > | NewConnection (const char *hostName, uint16_t port, const Io::SocketOptions &socketOptions, const Crt::Io::TlsContext &tlsContext, bool useWebsocket=false) noexcept
std::shared_ptr< MqttConnection > | NewConnection (const char *hostName, uint16_t port, const Io::SocketOptions &socketOptions, bool useWebsocket=false) noexcept

## Detailed Description

An MQTT client. This is a move-only type. Unless otherwise specified, all function arguments need only to live through the duration of the function call.

## Constructor & Destructor Documentation

## ◆ MqttClient() [1/3]

Aws::Crt::Mqtt::MqttClient::MqttClient | ( | Io::ClientBootstrap & | bootstrap,
|  | Allocator * | allocator = `g_allocator`
| ) |  |
| noexcept

Initialize an MqttClient using bootstrap and allocator

## ◆ ~MqttClient()

Aws::Crt::Mqtt::MqttClient::~MqttClient | ( |  | ) |

## ◆ MqttClient() [2/3]

Aws::Crt::Mqtt::MqttClient::MqttClient | ( | const MqttClient & |  | ) |
| delete

## ◆ MqttClient() [3/3]

Aws::Crt::Mqtt::MqttClient::MqttClient | ( | MqttClient && | toMove | ) |
| noexcept

## Member Function Documentation

## ◆ LastError()

int Aws::Crt::Mqtt::MqttClient::LastError | ( |  | ) | const
| noexcept

Returns
  the value of the last aws error encountered by operations on this instance.

## ◆ NewConnection() [1/2]

std::shared_ptr< MqttConnection > Aws::Crt::Mqtt::MqttClient::NewConnection | ( | const char * | hostName,
|  | uint16_t | port,
|  | const Io::SocketOptions & | socketOptions,
|  | bool | useWebsocket = `false`
| ) |  |
| noexcept

Create a new connection object over plain text from the client. The client must outlive all of its connection instances.

Parameters

  hostName | endpoint to connect to
  port | port to connect to
  socketOptions | socket options to use when establishing the connection
  useWebsocket | should the connection use websockets or should it use direct mqtt?

Returns
  a new connection object. Connect() will still need to be called after all further configuration is finished.

## ◆ NewConnection() [2/2]

std::shared_ptr< MqttConnection > Aws::Crt::Mqtt::MqttClient::NewConnection | ( | const char * | hostName,
|  | uint16_t | port,
|  | const Io::SocketOptions & | socketOptions,
|  | const Crt::Io::TlsContext & | tlsContext,
|  | bool | useWebsocket = `false`
| ) |  |
| noexcept

Create a new connection object using TLS from the client. The client must outlive all of its connection instances.

Parameters

  hostName | endpoint to connect to
  port | port to connect to
  socketOptions | socket options to use when establishing the connection
  tlsContext | tls context to use with the connection
  useWebsocket | should the connection use websockets or should it use direct mqtt?

Returns
  a new connection object. Connect() will still need to be called after all further configuration is finished.

## ◆ operator bool()

Aws::Crt::Mqtt::MqttClient::operator bool | ( |  | ) | const
| noexcept

Returns
  true if the instance is in a valid state, false otherwise.

## ◆ operator=() [1/2]

MqttClient & Aws::Crt::Mqtt::MqttClient::operator= | ( | const MqttClient & |  | ) |
| delete

## ◆ operator=() [2/2]

MqttClient & Aws::Crt::Mqtt::MqttClient::operator= | ( | MqttClient && | toMove | ) |
| noexcept

The documentation for this class was generated from the following files:

- crt/aws-crt-cpp/include/aws/crt/mqtt/MqttClient.h
- crt/aws-crt-cpp/source/mqtt/MqttClient.cpp