diff --git a/source/iot/Mqtt5Client.cpp b/source/iot/Mqtt5Client.cpp index 228d31d02..5b4d27b59 100644 --- a/source/iot/Mqtt5Client.cpp +++ b/source/iot/Mqtt5Client.cpp @@ -213,13 +213,13 @@ namespace Aws auto websocketConfig = m_websocketConfig.value(); auto signerTransform = [websocketConfig]( std::shared_ptr req, - const Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) - { + const Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) { // it is only a very happy coincidence that these function signatures match. This is the callback // for signing to be complete. It invokes the callback for websocket handshake to be complete. auto signingComplete = - [onComplete](const std::shared_ptr &req1, int errorCode) - { onComplete(req1, errorCode); }; + [onComplete](const std::shared_ptr &req1, int errorCode) { + onComplete(req1, errorCode); + }; auto signerConfig = websocketConfig.CreateSigningConfigCb(); @@ -643,13 +643,13 @@ namespace Aws auto websocketConfig = m_websocketConfig.value(); auto signerTransform = [websocketConfig]( std::shared_ptr req, - const Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) - { + const Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) { // it is only a very happy coincidence that these function signatures match. This is the callback // for signing to be complete. It invokes the callback for websocket handshake to be complete. auto signingComplete = - [onComplete](const std::shared_ptr &req1, int errorCode) - { onComplete(req1, errorCode); }; + [onComplete](const std::shared_ptr &req1, int errorCode) { + onComplete(req1, errorCode); + }; auto signerConfig = websocketConfig.CreateSigningConfigCb(); diff --git a/source/mqtt/Mqtt5ClientCore.cpp b/source/mqtt/Mqtt5ClientCore.cpp index 60eca72ce..4e52dfe0e 100644 --- a/source/mqtt/Mqtt5ClientCore.cpp +++ b/source/mqtt/Mqtt5ClientCore.cpp @@ -521,9 +521,7 @@ namespace Aws toSeat->SetHttpProxyOptions(*httpProxy); } return std::shared_ptr( - toSeat, - [allocator](Crt::Mqtt::MqttConnection *connection) - { + toSeat, [allocator](Crt::Mqtt::MqttConnection *connection) { connection->~MqttConnection(); aws_mem_release(allocator, reinterpret_cast(connection)); }); @@ -554,9 +552,7 @@ namespace Aws toSeat->SetHttpProxyOptions(*httpProxy); } return std::shared_ptr( - toSeat, - [allocator](Crt::Mqtt::MqttConnection *connection) - { + toSeat, [allocator](Crt::Mqtt::MqttConnection *connection) { connection->~MqttConnection(); aws_mem_release(allocator, reinterpret_cast(connection)); }); diff --git a/tests/Mqtt5ClientTest.cpp b/tests/Mqtt5ClientTest.cpp index af266d3c7..6c3a27c45 100644 --- a/tests/Mqtt5ClientTest.cpp +++ b/tests/Mqtt5ClientTest.cpp @@ -2538,18 +2538,17 @@ static int s_ConnectAndDisconnect(std::shared_ptr connectionCompletedPromise; std::promise connectionClosedPromise; auto onConnectionCompleted = - [&](Aws::Crt::Mqtt::MqttConnection &, int errorCode, Aws::Crt::Mqtt::ReturnCode returnCode, bool) - { - (void)returnCode; - if (errorCode) - { - connectionCompletedPromise.set_value(false); - } - else - { - connectionCompletedPromise.set_value(true); - } - }; + [&](Aws::Crt::Mqtt::MqttConnection &, int errorCode, Aws::Crt::Mqtt::ReturnCode returnCode, bool) { + (void)returnCode; + if (errorCode) + { + connectionCompletedPromise.set_value(false); + } + else + { + connectionCompletedPromise.set_value(true); + } + }; auto onDisconnect = [&](Aws::Crt::Mqtt::MqttConnection &) { connectionClosedPromise.set_value(); }; connection->OnConnectionCompleted = std::move(onConnectionCompleted); connection->OnDisconnect = std::move(onDisconnect); @@ -2735,10 +2734,11 @@ static int s_TestMqtt5to3AdapterWSConnectionMinimal(Aws::Crt::Allocator *allocat mqtt5Options.WithWebsocketHandshakeTransformCallback( [config, &Mqtt5WebSocket]( std::shared_ptr req, - const Aws::Crt::Mqtt5::OnWebSocketHandshakeInterceptComplete &onComplete) - { - auto signingComplete = [onComplete](const std::shared_ptr &req1, int errorCode) - { onComplete(req1, errorCode); }; + const Aws::Crt::Mqtt5::OnWebSocketHandshakeInterceptComplete &onComplete) { + auto signingComplete = + [onComplete](const std::shared_ptr &req1, int errorCode) { + onComplete(req1, errorCode); + }; auto signerConfig = config.CreateSigningConfigCb(); @@ -2753,18 +2753,20 @@ static int s_TestMqtt5to3AdapterWSConnectionMinimal(Aws::Crt::Allocator *allocat mqtt5TestVars.m_hostname_string.c_str(), mqtt5TestVars.m_port_value, socketOptions, true); ASSERT_TRUE(mqttConnection); - mqttConnection->WebsocketInterceptor = [config, &Mqtt3WebSocket]( - std::shared_ptr req, - const Aws::Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) - { - auto signingComplete = [onComplete](const std::shared_ptr &req1, int errorCode) - { onComplete(req1, errorCode); }; + mqttConnection->WebsocketInterceptor = + [config, &Mqtt3WebSocket]( + std::shared_ptr req, + const Aws::Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) { + auto signingComplete = + [onComplete](const std::shared_ptr &req1, int errorCode) { + onComplete(req1, errorCode); + }; - auto signerConfig = config.CreateSigningConfigCb(); + auto signerConfig = config.CreateSigningConfigCb(); - config.Signer->SignRequest(req, *signerConfig, signingComplete); - Mqtt3WebSocket = 1; - }; + config.Signer->SignRequest(req, *signerConfig, signingComplete); + Mqtt3WebSocket = 1; + }; int connectResult = s_ConnectAndDisconnect(mqttConnection); ASSERT_SUCCESS(connectResult);