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 10, 2024
1 parent 5b34a6d commit 6096eed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions samples/secure_tunneling/secure_tunnel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ int main(int argc, char *argv[])
* In a real world application you probably don't want to enforce synchronous behavior
* but this is a sample console application, so we'll just do that with a condition variable.
*/
std::promise<void> clientConnectedPromise;
std::promise<bool> clientStoppedPromise;

// service id storage for use in sample
Expand Down Expand Up @@ -285,6 +286,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "Sending Stream Start request\n");
secureTunnel->SendStreamStart();
}
clientConnectedPromise.set_value();
}
});

Expand Down Expand Up @@ -345,6 +347,8 @@ int main(int argc, char *argv[])
exit(-1);
}

clientConnectedPromise.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 6096eed

Please sign in to comment.