19 #include <aws/mqtt/client.h>
20 #include <aws/mqtt/v5/mqtt5_client.h>
41 class MqttConnectionCore final :
public std::enable_shared_from_this<MqttConnectionCore>
43 friend MqttConnection;
46 ~MqttConnectionCore();
47 MqttConnectionCore(
const MqttConnectionCore &) =
delete;
48 MqttConnectionCore(MqttConnectionCore &&) =
delete;
49 MqttConnectionCore &operator=(
const MqttConnectionCore &) =
delete;
50 MqttConnectionCore &operator=(MqttConnectionCore &&) =
delete;
56 operator bool() const noexcept;
82 bool SetWill(const
char *topic,
QOS qos,
bool retain, const
ByteBuf &payload) noexcept;
92 bool SetLogin(const
char *username, const
char *password) noexcept;
104 bool SetHttpProxyOptions(const Http::HttpClientConnectionProxyOptions &proxyOptions) noexcept;
118 bool SetReconnectTimeout(uint64_t min_seconds, uint64_t max_seconds) noexcept;
139 const
char *clientId,
141 uint16_t keepAliveTimeSecs,
142 uint32_t pingTimeoutMs,
143 uint32_t protocolOperationTimeoutMs,
144 bool setWebSocketInterceptor) noexcept;
151 bool Disconnect() noexcept;
154 aws_mqtt_client_connection *GetUnderlyingConnection() const noexcept;
170 const
char *topicFilter,
242 const MqttConnectionOperationStatistics &GetOperationStatistics() noexcept;
252 static
std::shared_ptr<MqttConnectionCore> s_createMqttConnectionCore(
253 aws_mqtt_client *client,
254 std::shared_ptr<MqttConnection> connection,
255 MqttConnectionOptions options) noexcept;
264 static
std::shared_ptr<MqttConnectionCore> s_createMqttConnectionCore(
265 aws_mqtt5_client *mqtt5Client,
266 std::shared_ptr<MqttConnection> connection,
267 MqttConnectionOptions options) noexcept;
269 static
void s_onConnectionTermination(
void *userData);
271 static
void s_onConnectionInterrupted(aws_mqtt_client_connection *,
int errorCode,
void *userData);
272 static
void s_onConnectionCompleted(
273 aws_mqtt_client_connection *,
275 enum aws_mqtt_connect_return_code returnCode,
279 static
void s_onConnectionSuccess(
280 aws_mqtt_client_connection *,
285 static
void s_onConnectionFailure(aws_mqtt_client_connection *,
int errorCode,
void *userData);
287 static
void s_onConnectionResumed(
288 aws_mqtt_client_connection *,
293 static
void s_onConnectionClosed(
294 aws_mqtt_client_connection *,
295 on_connection_closed_data *data,
298 static
void s_onDisconnect(aws_mqtt_client_connection *connection,
void *userData);
299 static
void s_onPublish(
300 aws_mqtt_client_connection *connection,
301 const aws_byte_cursor *topic,
302 const aws_byte_cursor *payload,
304 enum aws_mqtt_qos qos,
308 static
void s_onSubAck(
309 aws_mqtt_client_connection *connection,
311 const struct aws_byte_cursor *topic,
312 enum aws_mqtt_qos qos,
315 static
void s_onMultiSubAck(
316 aws_mqtt_client_connection *connection,
318 const struct aws_array_list *topicSubacks,
321 static
void s_onOpComplete(
322 aws_mqtt_client_connection *connection,
327 static
void s_onWebsocketHandshake(
328 struct aws_http_message *request,
330 aws_mqtt_transform_websocket_handshake_complete_fn *completeFn,
347 aws_mqtt_client *client,
348 aws_mqtt5_client *mqtt5Client,
349 std::shared_ptr<MqttConnection> connection,
350 MqttConnectionOptions options) noexcept;
352 void createUnderlyingConnection(aws_mqtt_client *mqttClient);
353 void createUnderlyingConnection(aws_mqtt5_client *mqtt5Client);
354 void connectionInit();
362 std::shared_ptr<MqttConnection> obtainConnectionInstance();
364 aws_mqtt_client_connection *m_underlyingConnection;
367 Crt::Io::TlsContext m_tlsContext;
368 Io::TlsConnectionOptions m_tlsOptions;
369 Io::SocketOptions m_socketOptions;
370 Crt::Optional<Http::HttpClientConnectionProxyOptions> m_proxyOptions;
374 MqttConnectionOperationStatistics m_operationStatistics;
383 std::weak_ptr<MqttConnection> m_connection;
390 std::shared_ptr<MqttConnectionCore> m_self;
std::function< void(MqttConnection &connection, uint16_t packetId, const Vector< String > &topics, QOS qos, int errorCode)> OnMultiSubAckHandler
Definition: MqttTypes.h:84
Definition: StringView.h:861
aws_byte_buf ByteBuf
Definition: Types.h:30
aws_mqtt_connect_return_code ReturnCode
Definition: Types.h:41
std::basic_string< char, std::char_traits< char >, StlAllocator< char >> String
Definition: Types.h:45
std::function< void(MqttConnection &connection, const String &topic, const ByteBuf &payload, bool dup, QOS qos, bool retain)> OnMessageReceivedHandler
Definition: MqttTypes.h:56
aws_allocator Allocator
Definition: Allocator.h:14
std::function< void(MqttConnection &connection, uint16_t packetId, int errorCode)> OnOperationCompleteHandler
Definition: MqttTypes.h:97
std::function< void(MqttConnection &connection, uint16_t packetId, const String &topic, QOS qos, int errorCode)> OnSubAckHandler
Definition: MqttTypes.h:68
AWS_CRT_CPP_API int LastError() noexcept
Definition: Api.cpp:425
std::vector< T, StlAllocator< T >> Vector
Definition: Types.h:53
aws_mqtt_qos QOS
Definition: Types.h:40
Definition: Allocator.h:10