Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Aug 2, 2023
1 parent 89ce57f commit 6db8deb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
16 changes: 8 additions & 8 deletions source/iot/Mqtt5Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ namespace Aws
auto websocketConfig = m_websocketConfig.value();
auto signerTransform = [websocketConfig](
std::shared_ptr<Crt::Http::HttpRequest> 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<Aws::Crt::Http::HttpRequest> &req1, int errorCode)
{ onComplete(req1, errorCode); };
[onComplete](const std::shared_ptr<Aws::Crt::Http::HttpRequest> &req1, int errorCode) {
onComplete(req1, errorCode);
};

auto signerConfig = websocketConfig.CreateSigningConfigCb();

Expand Down Expand Up @@ -643,13 +643,13 @@ namespace Aws
auto websocketConfig = m_websocketConfig.value();
auto signerTransform = [websocketConfig](
std::shared_ptr<Crt::Http::HttpRequest> 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<Aws::Crt::Http::HttpRequest> &req1, int errorCode)
{ onComplete(req1, errorCode); };
[onComplete](const std::shared_ptr<Aws::Crt::Http::HttpRequest> &req1, int errorCode) {
onComplete(req1, errorCode);
};

auto signerConfig = websocketConfig.CreateSigningConfigCb();

Expand Down
8 changes: 2 additions & 6 deletions source/mqtt/Mqtt5ClientCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,7 @@ namespace Aws
toSeat->SetHttpProxyOptions(*httpProxy);
}
return std::shared_ptr<Crt::Mqtt::MqttConnection>(
toSeat,
[allocator](Crt::Mqtt::MqttConnection *connection)
{
toSeat, [allocator](Crt::Mqtt::MqttConnection *connection) {
connection->~MqttConnection();
aws_mem_release(allocator, reinterpret_cast<void *>(connection));
});
Expand Down Expand Up @@ -554,9 +552,7 @@ namespace Aws
toSeat->SetHttpProxyOptions(*httpProxy);
}
return std::shared_ptr<Crt::Mqtt::MqttConnection>(
toSeat,
[allocator](Crt::Mqtt::MqttConnection *connection)
{
toSeat, [allocator](Crt::Mqtt::MqttConnection *connection) {
connection->~MqttConnection();
aws_mem_release(allocator, reinterpret_cast<void *>(connection));
});
Expand Down
54 changes: 28 additions & 26 deletions tests/Mqtt5ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2538,18 +2538,17 @@ static int s_ConnectAndDisconnect(std::shared_ptr<Aws::Crt::Mqtt::MqttConnection
std::promise<bool> connectionCompletedPromise;
std::promise<void> 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);
Expand Down Expand Up @@ -2735,10 +2734,11 @@ static int s_TestMqtt5to3AdapterWSConnectionMinimal(Aws::Crt::Allocator *allocat
mqtt5Options.WithWebsocketHandshakeTransformCallback(
[config, &Mqtt5WebSocket](
std::shared_ptr<Aws::Crt::Http::HttpRequest> req,
const Aws::Crt::Mqtt5::OnWebSocketHandshakeInterceptComplete &onComplete)
{
auto signingComplete = [onComplete](const std::shared_ptr<Aws::Crt::Http::HttpRequest> &req1, int errorCode)
{ onComplete(req1, errorCode); };
const Aws::Crt::Mqtt5::OnWebSocketHandshakeInterceptComplete &onComplete) {
auto signingComplete =
[onComplete](const std::shared_ptr<Aws::Crt::Http::HttpRequest> &req1, int errorCode) {
onComplete(req1, errorCode);
};

auto signerConfig = config.CreateSigningConfigCb();

Expand All @@ -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<Aws::Crt::Http::HttpRequest> req,
const Aws::Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete)
{
auto signingComplete = [onComplete](const std::shared_ptr<Aws::Crt::Http::HttpRequest> &req1, int errorCode)
{ onComplete(req1, errorCode); };
mqttConnection->WebsocketInterceptor =
[config, &Mqtt3WebSocket](
std::shared_ptr<Aws::Crt::Http::HttpRequest> req,
const Aws::Crt::Mqtt::OnWebSocketHandshakeInterceptComplete &onComplete) {
auto signingComplete =
[onComplete](const std::shared_ptr<Aws::Crt::Http::HttpRequest> &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);
Expand Down

0 comments on commit 6db8deb

Please sign in to comment.