reactor_send(const std::string &url, int c, int size, bool replying)
     : url_(url), sent_(0), confirmed_(0), total_(c),
       received_(0), received_bytes_(0), replying_(replying) {
     if (replying_)
         message_.reply_to("localhost/test");
     proton::binary content;
     content.assign((size_t) size, 'X');
     message_.body(content);
 }
    void on_message(proton::delivery &d, proton::message &m) override {
        std::cout << "Received " << m.body() << std::endl;

        std::string reply_to = m.reply_to();
        sender_map::iterator it = senders.find(reply_to);

        if (it == senders.end()) {
            std::cout << "No link for reply_to: " << reply_to << std::endl;
        } else {
            proton::sender sender = it->second;
            proton::message reply;

            reply.to(reply_to);
            reply.body(to_upper(proton::get<std::string>(m.body())));
            reply.correlation_id(m.correlation_id());

            sender.send(reply);
        }
    }
Exemple #3
0
 void on_message(proton::event &e, proton::delivery &d, proton::message &response) override {
     if (requests.empty()) return; // Spurious extra message!
     std::cout << requests.front() << " => " << response.body() << std::endl;
     requests.erase(requests.begin());
     if (!requests.empty()) {
         send_request();
     } else {
         d.connection().close();
     }
 }
Exemple #4
0
 void on_message(proton::delivery &d, proton::message &msg) override {
     if (msg.id().get<uint64_t>() < received)
         return; // ignore duplicate
     if (expected == 0 || received < expected) {
         std::cout << msg.body() << std::endl;
         received++;
     }
     if (received == expected) {
         d.receiver().close();
         d.connection().close();
     }
 }
 void on_message(proton::delivery &d, proton::message &msg) override {
     received_content_ = proton::get<proton::binary>(msg.body());
     received_bytes_ += received_content_.size();
     if (received_ < total_) {
         received_++;
     }
     d.settle();
     if (received_ == total_) {
         d.receiver().close();
         d.connection().close();
     }
 }
Exemple #6
0
    void on_message(proton::delivery &d, proton::message &msg) override {
        if (proton::coerce<uint64_t>(msg.id()) < received) {
            return; // Ignore duplicate
        }

        if (expected == 0 || received < expected) {
            std::cout << msg.body() << std::endl;
            received++;
        }

        if (received == expected) {
            d.receiver().close();
            d.connection().close();

            if (!!acceptor) acceptor.close();
        }
    }
Exemple #7
0
 void on_message(proton::delivery &, proton::message &m) override {
     std::cout << m.body() << std::endl;
 }