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


C++ OTData::get方法代码示例

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


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

示例1: while

TEST_F(Test_RouterDealer, Dealer_3_Router_Dealer_Router)
{
    ASSERT_NE(nullptr, &Test_RouterDealer::context_.get());

    auto dealerCallback =
        zmq::ListenCallback::Factory([this](zeromq::Message& input) -> void {
            EXPECT_EQ(3, input.size());
            const std::string& inputString = *input.Body().begin();
            bool match = inputString == testMessage_ ||
                         inputString == testMessage2_ ||
                         inputString == testMessage3_;

            EXPECT_TRUE(match);

            auto sent = routerSocket_->get().Send(input);

            EXPECT_TRUE(sent);

            ++callbackFinishedCount_;
        });

    ASSERT_NE(nullptr, &dealerCallback.get());

    auto dealerSocket = zmq::DealerSocket::Factory(
        Test_RouterDealer::context_,
        zmq::Socket::Direction::Bind,
        dealerCallback);

    ASSERT_NE(nullptr, &dealerSocket.get());
    ASSERT_EQ(SocketType::Dealer, dealerSocket->Type());

    dealerSocket->SetTimeouts(
        std::chrono::milliseconds(0),
        std::chrono::milliseconds(30000),
        std::chrono::milliseconds(-1));
    dealerSocket->Start(dealerEndpoint_);

    dealerSocket_ = &dealerSocket;

    auto routerCallback =
        zmq::ListenCallback::Factory([this](zeromq::Message& input) -> void {
            EXPECT_EQ(3, input.size());
            const std::string& inputString = *input.Body().begin();
            bool match = inputString == testMessage_ ||
                         inputString == testMessage2_ ||
                         inputString == testMessage3_;

            EXPECT_TRUE(match);

            auto sent = dealerSocket_->get().Send(input);

            EXPECT_TRUE(sent);

            ++callbackFinishedCount_;
        });

    ASSERT_NE(nullptr, &routerCallback.get());

    auto routerSocket = zmq::RouterSocket::Factory(
        Test_RouterDealer::context_,
        zmq::Socket::Direction::Bind,
        routerCallback);

    ASSERT_NE(nullptr, &routerSocket.get());
    ASSERT_EQ(SocketType::Router, routerSocket->Type());

    routerSocket->SetTimeouts(
        std::chrono::milliseconds(0),
        std::chrono::milliseconds(-1),
        std::chrono::milliseconds(30000));
    routerSocket->Start(routerEndpoint_);

    routerSocket_ = &routerSocket;

    std::vector<OTZMQMessage> replyMessages;

    auto clientRouterCallback = zmq::ListenCallback::Factory(
        [this, &replyMessages](const network::zeromq::Message& input) -> void {
            const std::string& inputString = *input.Body().begin();
            bool match = inputString == testMessage_ ||
                         inputString == testMessage2_ ||
                         inputString == testMessage3_;

            EXPECT_TRUE(match);

            auto replyMessage = zeromq::Message::Factory();
            for (auto it = input.begin(); it != input.end(); ++it) {
                auto& frame = *it;
                if (0 < frame.size()) {
                    OTData data = Data::Factory(frame.data(), frame.size());
                    replyMessage->AddFrame(data.get());
                } else {
                    replyMessage->AddFrame();
                }
            }
            replyMessages.push_back(replyMessage);

            ++callbackFinishedCount_;
        });

//.........这里部分代码省略.........
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:101,代码来源:Test_RouterDealer.cpp


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