Skip to content

Commit

Permalink
Add promise to secure tunnel sample
Browse files Browse the repository at this point in the history
  • Loading branch information
sfodagain committed Sep 9, 2024
1 parent d49f5df commit a7b2e7a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions samples/secure_tunneling/secure_tunnel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,15 @@ int main(int argc, char *argv[])
}
});

std::promise<void> connectionPromise;

builder.WithOnConnectionSuccess([&](SecureTunnel *secureTunnel, const ConnectionSuccessEventData &eventData) {
logConnectionData(eventData);

/* Stream Start can only be called from Source Mode */
if (localProxyMode == AWS_SECURE_TUNNELING_SOURCE_MODE)
{
connectionPromise.set_value();
/* Use a Multiplexing (Service Id) if available on this Secure Tunnel */
if (eventData.connectionData->getServiceId1().has_value())
{
Expand Down Expand Up @@ -345,6 +348,8 @@ int main(int argc, char *argv[])
exit(-1);
}

connectionPromise.get_future().wait_for(std::chrono::seconds(5));

/*
* In Destination mode the Secure Tunnel Client will remain open and echo messages that come in.
* In Source mode the Secure Tunnel Client will send 4 messages and then disconnect and terminate.
Expand Down

0 comments on commit a7b2e7a

Please sign in to comment.