Пример #1
0
void session::handle_start(const code& ec, channel::ptr channel,
    result_handler handle_started, result_handler handle_stopped)
{
    // Must either stop or subscribe the channel for stop before returning.
    if (ec)
        channel->stop(ec);
    else
        channel->subscribe_stop(handle_stopped);

    // This is the end of the registration sequence.
    handle_started(ec);
}
Пример #2
0
void session::handle_start(const code& ec, channel::ptr channel,
    result_handler handle_started, result_handler handle_stopped)
{
    // Must either stop or subscribe the channel for stop before returning.
    // All closures must eventually be invoked as otherwise it is a leak.
    // Therefore upon start failure expect start failure and stop callbacks.
    if (ec)
    {
        channel->stop(ec);
        handle_stopped(ec);
    }
    else
    {
        channel->subscribe_stop(
            BIND_3(do_remove, _1, channel, handle_stopped));
    }

    // This is the end of the registration sequence.
    handle_started(ec);
}
Пример #3
0
void protocol::start_talking(channel::ptr node,
    proxy::stop_handler handle_stop, bool relay)
{
    node->subscribe_stop(handle_stop);

    // Notify protocol subscribers of new channel.
    channel_subscriber_->relay(error::success, node);

    const auto callback = 
        dispatch_.ordered_delegate(&protocol::handle_handshake,
            this, _1, node);

    // TODO: set height.
    const uint32_t blockchain_height = 0;

    // Attach version protocol to the new connection (until complete).
    std::make_shared<protocol_version>(node, pool_, timeouts_.handshake,
        callback, hosts_, self_, blockchain_height, relay)->start();

    // Start reading from the socket (causing subscription events).
    node->start();
}