Пример #1
0
static int subscribe_result(p2p& network)
{
    std::promise<code> promise;
    const auto handler = [&promise](const code& ec, channel::ptr)
    {
        promise.set_value(ec);
    };
    network.subscribe(handler);
    return promise.get_future().get().value();
}
Пример #2
0
static int subscribe_result(p2p& network, const config::endpoint& host)
{
    std::promise<code> promise;
    const auto handler = [&promise](const code& ec, channel::ptr)
    {
        promise.set_value(ec);
    };
    network.subscribe(handler);
    network.connect(host.host(), host.port());
    return promise.get_future().get().value();
}