With only the asynchronous API, you're stuck having to chain one asynchronous operation within the handler of another:
// off the top of my head, not tested
client->connect([&](AsyncResult<size_t> result)
{
result.get(); // throws if the connect operation failed
client->join([&](AsyncResult<SessionId> result)
{
auto sessionId = result.get(); // throws if the join operation failed
// Do other stuff after joining...
});
});
If you don't like nesting lambda function handlers within lambda function handlers, you can use the technique I show in the Async API tutorial page, near the bottom where it says:
The following example shows how to call member functions within asynchronous handlers, and how to chain one asynchronous operation after another:
Alternatively, you can wait until I implement the future-based API, and use continuations to chain one async operation after another.
Hope this helps.