Exemplo n.º 1
0
void p2p::handle_new_connection(const code& ec, channel::ptr channel,
    result_handler handler)
{
    // Connection-in-use indicated here by error::address_in_use.
    handler(ec);
    
    if (!ec && channel->notify())
        channel_subscriber_->relay(error::success, channel);
}
Exemplo n.º 2
0
code p2p::store(channel::ptr channel)
{
    const auto address = channel->authority();
    const auto match = [&address](const channel::ptr& element)
    {
        return element->authority() == address;
    };

    // May return error::address_in_use.
    const auto ec = pending_close_.store(channel, match);

    if (!ec && channel->notify())
        channel_subscriber_->relay(error::success, channel);

    return ec;
}