本文整理汇总了C++中proton::event类的典型用法代码示例。如果您正苦于以下问题:C++ event类的具体用法?C++ event怎么用?C++ event使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_accepted
void on_accepted(proton::event &e) {
confirmed_++;
e.delivery().settle();
if (confirmed_ == total_) {
std::cout << "all messages confirmed" << std::endl;
if (!replying_)
e.connection().close();
}
}
示例2: on_message
void on_message(proton::event &e) {
if (requests.empty()) return; // Spurious extra message!
proton::message& response = e.message();
std::cout << requests.front() << " => " << response.body() << std::endl;
requests.erase(requests.begin());
if (!requests.empty()) {
send_request();
} else {
e.connection().close();
}
}
示例3: on_message
void on_message(proton::event &e) {
std::cout << "Received " << e.message().body() << std::endl;
std::string reply_to = e.message().reply_to();
proton::message reply;
reply.address(reply_to);
reply.body(to_upper(e.message().body().get<std::string>()));
reply.correlation_id(e.message().correlation_id());
if (!senders[reply_to])
senders[reply_to] = e.connection().open_sender(reply_to);
senders[reply_to].send(reply);
}
示例4: on_message
void on_message(proton::event &e) {
proton::message &msg = e.message();
msg.body().decode() >> received_content_;
received_bytes_ += received_content_.size();
if (received_ < total_) {
received_++;
}
e.delivery().settle();
if (received_ == total_) {
e.receiver().close();
e.connection().close();
}
}
示例5: on_connection_open
void on_connection_open(proton::event &e) {
std::cout << "Inbound server connection connected via SSL. Protocol: " <<
e.connection().transport().ssl().protocol() << std::endl;
if (e.connection().transport().sasl().outcome() == sasl::OK) {
std::string subject = e.connection().transport().ssl().remote_subject();
std::cout << "Inbound client certificate identity " << find_CN(subject) << std::endl;
}
else {
std::cout << "Inbound client authentication failed" <<std::endl;
e.connection().close();
}
inbound_listener.close();
}
示例6: on_message
void on_message(proton::event &e) {
proton::message& msg = e.message();
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) {
e.receiver().close();
e.connection().close();
if (!!acceptor) acceptor.close();
}
}
示例7: on_link_opening
void on_link_opening(proton::event &e) {
proton::link& lnk = e.link();
if (lnk.is_sender()) {
proton::sender &sender(lnk.sender());
proton::terminus &remote_source(lnk.remote_source());
if (remote_source.is_dynamic()) {
std::string address = queue_name();
lnk.source().address(address);
queue *q = new queue(true);
queues[address] = q;
q->subscribe(sender);
std::cout << "broker dynamic outgoing link from " << address << std::endl;
}
else {
std::string address = remote_source.address();
if (!address.empty()) {
lnk.source().address(address);
get_queue(address).subscribe(sender);
std::cout << "broker outgoing link from " << address << std::endl;
}
}
}
else {
std::string address = lnk.remote_target().address();
if (!address.empty())
lnk.target().address(address);
std::cout << "broker incoming link to " << address << std::endl;
}
}
示例8: on_sendable
void on_sendable(proton::event &e) {
proton::link lnk = e.link();
std::string address = lnk.local_source().address();
proton::sender s = lnk.sender();
queues_.get(address).dispatch(&s);
}
示例9: on_link_close
void on_link_close(proton::event &e) {
proton::link lnk = e.link();
if (!!lnk.sender()) {
unsubscribe(lnk.sender());
}
}
示例10: on_delivery_accept
void on_delivery_accept(proton::event &e) {
confirmed++;
if (confirmed == total) {
std::cout << "all messages confirmed" << std::endl;
e.connection().close();
acceptor.close();
}
}
示例11: on_message
void
on_message ( proton::event &e )
{
log ( "on_message" );
double receive_timestamp = get_timestamp();
proton::message& msg = e.message();
double send_timestamp = msg.body().get<double>();
double latency = receive_timestamp - send_timestamp;
fprintf ( output_fp, "latency %.6lf\n", latency );
if ( ! received )
{
rr_init ( & resource_reporter );
}
if ( (expected == 0)
||
(expected == -1)
||
(received < expected)
)
{
received++;
if ( ! ( received % report_frequency ) )
{
report ( output_fp );
}
if (received == expected)
{
log ( "closing receiver and connection." );
e.receiver().close();
e.connection().close();
char filename[1000];
sprintf ( filename, "/tmp/simple_recv_%d_is_done", getpid() );
FILE * fp = fopen ( filename, "w" );
fprintf ( fp, ":-)\n" );
fclose ( fp );
}
}
}
示例12: on_sendable
void on_sendable(proton::event &e) {
proton::sender sender = e.sender();
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++;
}
}
示例13: on_sendable
void on_sendable(proton::event &e) {
proton::sender sender = e.sender();
while (sender.credit() && sent_ < total_) {
id_value_ = sent_ + 1;
message_.correlation_id(id_value_);
proton::amqp_timestamp reactor_now(reactor_.now());
message_.creation_time(reactor_now);
sender.send(message_);
sent_++;
}
}
示例14: on_start
void on_start(proton::event &e) {
// Configure listener. Details vary by platform.
ssl_certificate server_cert = platform_certificate("tserver", "tserverpw");
std::string client_CA = platform_CA("tclient");
// Specify an SSL domain with CA's for client certificate verification.
server_domain sdomain(server_cert, client_CA);
connection_options server_opts;
server_opts.server_domain(sdomain).handler(&s_handler);
server_opts.allowed_mechs("EXTERNAL");
e.container().server_connection_options(server_opts);
// Configure client.
ssl_certificate client_cert = platform_certificate("tclient", "tclientpw");
std::string server_CA = platform_CA("tserver");
client_domain cdomain(client_cert, server_CA);
connection_options client_opts;
client_opts.client_domain(cdomain).allowed_mechs("EXTERNAL");
// Validate the server certificate against this name:
client_opts.peer_hostname("test_server");
e.container().client_connection_options(client_opts);
s_handler.inbound_listener = e.container().listen(url);
e.container().open_sender(url);
}
示例15: on_link_open
void on_link_open(proton::event &e) {
proton::link lnk = e.link();
if (!!lnk.sender()) {
proton::terminus remote_source(lnk.remote_source());
queue &q = remote_source.dynamic() ?
queues_.dynamic() : queues_.get(remote_source.address());
lnk.local_source().address(q.name());
q.subscribe(lnk.sender());
std::cout << "broker outgoing link from " << q.name() << std::endl;
} else {
// Receiver
std::string address = lnk.remote_target().address();
if (!address.empty()) {
lnk.local_target().address(address);
std::cout << "broker incoming link to " << address << std::endl;
}
}
}