当前位置: 首页>>代码示例>>C++>>正文


C++ channel_ptr::subscribe_stop方法代码示例

本文整理汇总了C++中channel_ptr::subscribe_stop方法的典型用法代码示例。如果您正苦于以下问题:C++ channel_ptr::subscribe_stop方法的具体用法?C++ channel_ptr::subscribe_stop怎么用?C++ channel_ptr::subscribe_stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在channel_ptr的用法示例。


在下文中一共展示了channel_ptr::subscribe_stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handle_accept

void protocol::handle_accept(const std::error_code& ec, channel_ptr node,
    acceptor_ptr accept)
{
    accept->accept(
        strand_.wrap(std::bind(&protocol::handle_accept,
            this, _1, _2, accept)));
    if (ec)
    {
        log_error(LOG_PROTOCOL)
            << "Problem accepting connection: " << ec.message();
        return;
    }
    accepted_channels_.push_back(node);
    log_info(LOG_PROTOCOL) << "Accepted connection: "
        << accepted_channels_.size();
    auto handshake_complete = [this, node](const std::error_code& ec)
    {
        if (ec)
        {
            log_error(LOG_PROTOCOL) << "Problem with handshake: "
                << ec.message();
            return;
        }
        // Remove channel from list of connections
        node->subscribe_stop(
            strand_.wrap(std::bind(&protocol::inbound_channel_stopped,
                this, _1, node)));
        setup_new_channel(node);
    };
    handshake_.ready(node, handshake_complete);
}
开发者ID:RagnarDanneskjold,项目名称:libbitcoin,代码行数:31,代码来源:protocol.cpp

示例2: handle_connect

void protocol::handle_connect(
    const std::error_code& ec, channel_ptr node,
    const network_address_type& address, slot_index slot)
{
    BITCOIN_ASSERT(connect_states_[slot] == connect_state::connecting);
    connect_states_[slot] = connect_state::established;
    BITCOIN_ASSERT(connections_.size() <= max_outbound_);
    if (ec)
    {
        log_warning(LOG_PROTOCOL) << "Unable to connect to "
            << pretty(address.ip) << ":" << address.port
            << " - " << ec.message();
        // Retry another connection
        // Still in same strand.
        try_connect_once(slot);
        return;
    }
    connections_.push_back({address, node});
    log_info(LOG_PROTOCOL) << "Connected to "
        << pretty(address.ip) << ":" << address.port
        << " (" << connections_.size() << " connections)";
    // Remove channel from list of connections
    node->subscribe_stop(
        strand_.wrap(std::bind(&protocol::outbound_channel_stopped,
            this, _1, node, slot)));
    setup_new_channel(node);
}
开发者ID:RagnarDanneskjold,项目名称:libbitcoin,代码行数:27,代码来源:protocol.cpp

示例3: handle_handshake

void handle_handshake(const std::error_code& ec, channel_ptr node,
    handshake_ptr hs)
{
    if (ec)
        error_exit(ec.message());
    log_info() << "Connected";
    channode = node;
    node->subscribe_stop(handle_stop);
}
开发者ID:Phallanx,项目名称:libbitcoin,代码行数:9,代码来源:chanstop.cpp

示例4: setup_new_channel

void protocol::setup_new_channel(channel_ptr node)
{
    // Remove channel from list of connections
    node->subscribe_stop(
        strand_.wrap(std::bind(&protocol::channel_stopped,
            this, _1, node)));
    subscribe_address(node);
    node->send(get_address_type(), handle_send);
    // Notify subscribers
    channel_subscribe_->relay(std::error_code(), node);
}
开发者ID:genba,项目名称:libbitcoin,代码行数:11,代码来源:protocol.cpp

示例5: accepted_connection

void accepted_connection(const std::error_code& ec, channel_ptr node,
    acceptor_ptr accept)
{
    if (ec)
    {
        log_error() << "Accept: " << ec.message();
        return;
    }
    log_info() << "Accepted connection!";
    node->subscribe_stop(node_stopped);
    // Now we need to keep it alive otherwise the connection is closed.
    node->subscribe_version(
        std::bind(version_received, _1, _2, node));
    // Keep accepting more connections.
    accept->accept(
        std::bind(accepted_connection, _1, _2, accept));
}
开发者ID:RagnarDanneskjold,项目名称:libbitcoin,代码行数:17,代码来源:accept.cpp

示例6: handle_manual_connect

void protocol::handle_manual_connect(
    const std::error_code& ec, channel_ptr node,
    const std::string& hostname, uint16_t port)
{
    if (ec)
    {
        log_warning(LOG_PROTOCOL) << "Manual connection to "
                                  << hostname << ":" << port << " failed with " << ec.message();
        maintain_connection(hostname, port);
        return;
    }
    manual_connections_.push_back(node);
    // Connected!
    log_info(LOG_PROTOCOL) << "Manual connection established: "
                           << hostname << ":" << port;
    // Remove channel from list of connections
    node->subscribe_stop(strand_.wrap(
                             &protocol::manual_channel_stopped, this, _1, node, hostname, port));
    setup_new_channel(node);
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:20,代码来源:protocol.cpp


注:本文中的channel_ptr::subscribe_stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。