// protected:
void session::start_channel(channel::ptr channel,
    result_handler handle_started)
{
    channel->set_notify(notify_on_connect_);
    channel->set_nonce(pseudo_random(1, max_uint64));

    // The channel starts, invokes the handler, then starts the read cycle.
    channel->start(
        BIND_3(handle_starting, _1, channel, handle_started));
}
void session::handle_pend(const code& ec, channel::ptr channel,
    result_handler handle_started)
{
    if (ec)
    {
        handle_started(ec);
        return;
    }

    // The channel starts, invokes the handler, then starts the read cycle.
    channel->start(
        BIND_3(handle_channel_start, _1, channel, handle_started));
}
Beispiel #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();
}