本文整理汇总了C++中proton::sender类的典型用法代码示例。如果您正苦于以下问题:C++ sender类的具体用法?C++ sender怎么用?C++ sender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_send
// work_queue work items is are automatically dequeued and called by proton
// This function is called because it was queued by send()
void do_send(const proton::message& m) {
sender_.send(m);
std::lock_guard<std::mutex> l(lock_);
--queued_; // work item was consumed from the work_queue
credit_ = sender_.credit(); // update credit
sender_ready_.notify_all(); // Notify senders we have space on queue
}
示例2: on_sender_open
void on_sender_open(proton::sender &sender) override {
if (sender.source().dynamic()) {
std::string addr = generate_address();
sender.open(proton::sender_options().source(proton::source_options().address(addr)));
senders[addr] = sender;
}
}
示例3: on_sender_open
void on_sender_open(proton::sender& s) override {
auto a = s.source().address();
std::cout << s << ": New incoming sender: source address: " << a << "\n";
if (a==c_quit) {
s.container().stop();
}
}
示例4: send_available_messages
void send_available_messages(proton::sender &s) {
for (int i = sequence; available && s.credit() > 0; i++) {
std::ostringstream mbody;
mbody << "flow_sender message " << sequence++;
proton::message m(mbody.str());
s.send(m);
available--;
}
}
示例5: on_sendable
void on_sendable(proton::sender &sender) override {
while (sender.credit() && sent_ < total_) {
id_value_ = sent_ + 1;
message_.correlation_id(id_value_);
message_.creation_time(proton::timestamp::now());
sender.send(message_);
sent_++;
}
}
示例6: on_sendable
void on_sendable(proton::event &e, proton::sender &sender) override {
while (sender.credit() && sent < total) {
proton::message msg;
msg.id(sent + 1);
std::map<std::string, int> m;
m["sequence"] = sent+1;
msg.body(m);
sender.send(msg);
sent++;
}
}
示例7: send_request
void send_request() {
proton::message req;
req.body(requests.front());
req.reply_to(receiver.remote_source().address());
sender.send(req);
}
示例8: unsubscribe
void unsubscribe(proton::sender lnk) {
std::string address = lnk.local_source().address();
if (queues_.get(address).unsubscribe(lnk)) {
queues_.erase(address);
}
}
示例9: unsubscribe
void unsubscribe (proton::sender &lnk) {
std::string address = lnk.source().address();
queue_map::iterator it = queues.find(address);
if (it != queues.end() && it->second->unsubscribe(lnk)) {
delete it->second;
queues.erase(it);
}
}
示例10: do_send
// Only called if we have credit. Return true if we sent a message.
bool do_send(queue* q, proton::sender &s) {
proton::message m;
bool popped = q->pop(m, has_messages_callback_);
if (popped)
s.send(m);
/// if !popped the queue has saved the callback for later.
return popped;
}
示例11: on_sender_open
void on_sender_open(proton::sender &sender) override {
if (sender.remote_source().dynamic()) {
sender.local_source().address(generate_address());
senders[sender.local_source().address()] = sender;
}
}
示例12: on_sendable
void on_sendable(proton::event &e, proton::sender &s) override {
proton::message m;
m.body("Hello World!");
s.send(m);
s.close();
}
示例13: on_sendable
void on_sendable(proton::sender& s) override {
std::lock_guard<std::mutex> l(lock_);
credit_ = s.credit();
sender_ready_.notify_all(); // Notify senders we have credit
}
示例14: on_sender_open
void on_sender_open(proton::sender& s) override {
// Make sure sender_ and work_queue_ are set atomically
std::lock_guard<std::mutex> l(lock_);
sender_ = s;
work_queue_ = &s.work_queue();
}
示例15: close
// Thread safe
void close() {
work_queue()->add([=]() { sender_.connection().close(); });
}