PROTON-1083: [C++ binding] Simplify messaging_handler and messaging_event - Consistently name events with a noun form eg OPEN/CLOSE (rather than opened/closed). - Only have endpoint events corresponding to remote open etc. This removes opening/closing events - as we are doing the local operations we should already know about them and not need events. - Fill in missing event dispatches.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c12eae18 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c12eae18 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c12eae18 Branch: refs/heads/master Commit: c12eae180ab79982e6c2024f58f0c28001f84315 Parents: 3972720 Author: Andrew Stitcher <[email protected]> Authored: Tue Dec 15 15:20:31 2015 +0000 Committer: Andrew Stitcher <[email protected]> Committed: Fri Dec 18 13:48:38 2015 +0000 ---------------------------------------------------------------------- examples/cpp/broker.hpp | 8 +- examples/cpp/client.cpp | 2 +- examples/cpp/connection_options.cpp | 4 +- examples/cpp/direct_send.cpp | 4 +- examples/cpp/helloworld_direct.cpp | 4 +- examples/cpp/server_direct.cpp | 2 +- examples/cpp/simple_send.cpp | 4 +- examples/cpp/ssl.cpp | 6 +- examples/cpp/ssl_client_cert.cpp | 6 +- .../cpp/include/proton/messaging_adapter.hpp | 28 ++- .../cpp/include/proton/messaging_handler.hpp | 47 +++-- proton-c/bindings/cpp/src/messaging_adapter.cpp | 170 +++++-------------- proton-c/bindings/cpp/src/messaging_event.cpp | 104 ++++++------ proton-c/bindings/cpp/src/messaging_event.hpp | 45 ++--- proton-c/bindings/cpp/src/messaging_handler.cpp | 35 ++-- 15 files changed, 172 insertions(+), 297 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/broker.hpp ---------------------------------------------------------------------- diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp index 2d94b5a..4cd4f4b 100644 --- a/examples/cpp/broker.hpp +++ b/examples/cpp/broker.hpp @@ -135,7 +135,7 @@ class broker_handler : public proton::messaging_handler { public: broker_handler(queues& qs) : queues_(qs) {} - void on_link_opening(proton::event &e) { + void on_link_open(proton::event &e) { proton::link lnk = e.link(); if (!!lnk.sender()) { proton::terminus remote_source(lnk.remote_source()); @@ -160,17 +160,17 @@ class broker_handler : public proton::messaging_handler { queues_.erase(address); } - void on_link_closing(proton::event &e) { + void on_link_close(proton::event &e) { proton::link lnk = e.link(); if (!!lnk.sender()) unsubscribe(lnk.sender()); } - void on_connection_closing(proton::event &e) { + void on_connection_close(proton::event &e) { remove_stale_consumers(e.connection()); } - void on_disconnected(proton::event &e) { + void on_disconnect(proton::event &e) { remove_stale_consumers(e.connection()); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/client.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp index 7e576b1..4dee119 100644 --- a/examples/cpp/client.cpp +++ b/examples/cpp/client.cpp @@ -50,7 +50,7 @@ class client : public proton::messaging_handler { sender.send(req); } - void on_link_opened(proton::event &e) { + void on_link_open(proton::event &e) { if (e.link() == receiver) send_request(); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/connection_options.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp index ab21f76..6a79224 100644 --- a/examples/cpp/connection_options.cpp +++ b/examples/cpp/connection_options.cpp @@ -29,7 +29,7 @@ using proton::connection_options; class handler_2 : public proton::messaging_handler { - void on_connection_opened(proton::event &e) { + void on_connection_open(proton::event &e) { std::cout << "connection events going to handler_2" << std::endl; std::cout << "connection max_frame_size: " << e.connection().transport().max_frame_size() << ", idle timeout: " << e.connection().transport().idle_timeout() << std::endl; @@ -51,7 +51,7 @@ class main_handler : public proton::messaging_handler { e.container().connect(url, connection_options().handler(&conn_handler).max_frame_size(2468)); } - void on_connection_opened(proton::event &e) { + void on_connection_open(proton::event &e) { std::cout << "unexpected connection event on main handler" << std::endl; e.connection().close(); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/direct_send.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp index 909ef3f..0b7095e 100644 --- a/examples/cpp/direct_send.cpp +++ b/examples/cpp/direct_send.cpp @@ -59,7 +59,7 @@ class simple_send : public proton::messaging_handler { } } - void on_accepted(proton::event &e) { + void on_delivery_accept(proton::event &e) { confirmed++; if (confirmed == total) { std::cout << "all messages confirmed" << std::endl; @@ -68,7 +68,7 @@ class simple_send : public proton::messaging_handler { } } - void on_disconnected(proton::event &e) { + void on_disconnect(proton::event &e) { sent = confirmed; } }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/helloworld_direct.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp index 826b371..5e4c316 100644 --- a/examples/cpp/helloworld_direct.cpp +++ b/examples/cpp/helloworld_direct.cpp @@ -48,11 +48,11 @@ class hello_world_direct : public proton::messaging_handler { std::cout << e.message().body() << std::endl; } - void on_accepted(proton::event &e) { + void on_delivery_accept(proton::event &e) { e.connection().close(); } - void on_connection_closed(proton::event &e) { + void on_connection_close(proton::event &e) { acceptor.close(); } }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/server_direct.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp index 8bbcefe..7ad5889 100644 --- a/examples/cpp/server_direct.cpp +++ b/examples/cpp/server_direct.cpp @@ -61,7 +61,7 @@ class server : public proton::messaging_handler { return addr.str(); } - void on_link_opening(proton::event& e) { + void on_link_open(proton::event& e) { proton::link link = e.link(); if (!!link.sender() && link.remote_source().dynamic()) { link.source().address(generate_address()); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/simple_send.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp index 4d056fc..64c34bf 100644 --- a/examples/cpp/simple_send.cpp +++ b/examples/cpp/simple_send.cpp @@ -57,7 +57,7 @@ class simple_send : public proton::messaging_handler { } } - void on_accepted(proton::event &e) { + void on_delivery_accept(proton::event &e) { confirmed++; if (confirmed == total) { std::cout << "all messages confirmed" << std::endl; @@ -65,7 +65,7 @@ class simple_send : public proton::messaging_handler { } } - void on_disconnected(proton::event &e) { + void on_disconnect(proton::event &e) { sent = confirmed; } }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/ssl.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp index 5e670c2..568e223 100644 --- a/examples/cpp/ssl.cpp +++ b/examples/cpp/ssl.cpp @@ -44,7 +44,7 @@ std::string find_CN(const std::string &); struct server_handler : public proton::messaging_handler { proton::acceptor acceptor; - void on_connection_opened(proton::event &e) { + void on_connection_open(proton::event &e) { std::cout << "Inbound server connection connected via SSL. Protocol: " << e.connection().transport().ssl().protocol() << std::endl; acceptor.close(); @@ -83,7 +83,7 @@ class hello_world_direct : public proton::messaging_handler { e.container().open_sender(url); } - void on_connection_opened(proton::event &e) { + void on_connection_open(proton::event &e) { std::string subject = e.connection().transport().ssl().remote_subject(); std::cout << "Outgoing client connection connected via SSL. Server certificate identity " << find_CN(subject) << std::endl; @@ -96,7 +96,7 @@ class hello_world_direct : public proton::messaging_handler { e.sender().close(); } - void on_accepted(proton::event &e) { + void on_delivery_accept(proton::event &e) { // All done. e.connection().close(); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/examples/cpp/ssl_client_cert.cpp ---------------------------------------------------------------------- diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp index 0be0c32..7a9f411 100644 --- a/examples/cpp/ssl_client_cert.cpp +++ b/examples/cpp/ssl_client_cert.cpp @@ -46,7 +46,7 @@ std::string find_CN(const std::string &); struct server_handler : public proton::messaging_handler { proton::acceptor inbound_listener; - void on_connection_opened(proton::event &e) { + 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) { @@ -99,7 +99,7 @@ class hello_world_direct : public proton::messaging_handler { e.container().open_sender(url); } - void on_connection_opened(proton::event &e) { + void on_connection_open(proton::event &e) { std::string subject = e.connection().transport().ssl().remote_subject(); std::cout << "Outgoing client connection connected via SSL. Server certificate identity " << find_CN(subject) << std::endl; @@ -112,7 +112,7 @@ class hello_world_direct : public proton::messaging_handler { e.sender().close(); } - void on_accepted(proton::event &e) { + void on_delivery_accept(proton::event &e) { // All done. e.connection().close(); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp index 6e4342d..4e765e2 100644 --- a/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp +++ b/proton-c/bindings/cpp/include/proton/messaging_adapter.hpp @@ -42,31 +42,23 @@ class messaging_adapter : public messaging_handler PN_CPP_EXTERN virtual void on_link_flow(event &e); PN_CPP_EXTERN virtual void on_delivery(event &e); PN_CPP_EXTERN virtual void on_unhandled(event &e); - PN_CPP_EXTERN virtual void on_connection_closed(event &e); - PN_CPP_EXTERN virtual void on_connection_closing(event &e); - PN_CPP_EXTERN virtual void on_connection_error(event &e); - PN_CPP_EXTERN virtual void on_connection_local_open(event &e); PN_CPP_EXTERN virtual void on_connection_remote_open(event &e); PN_CPP_EXTERN virtual void on_connection_remote_close(event &e); - PN_CPP_EXTERN virtual void on_connection_opened(event &e); - PN_CPP_EXTERN virtual void on_connection_opening(event &e); - PN_CPP_EXTERN virtual void on_session_closed(event &e); - PN_CPP_EXTERN virtual void on_session_closing(event &e); - PN_CPP_EXTERN virtual void on_session_error(event &e); - PN_CPP_EXTERN virtual void on_session_local_open(event &e); PN_CPP_EXTERN virtual void on_session_remote_open(event &e); PN_CPP_EXTERN virtual void on_session_remote_close(event &e); - PN_CPP_EXTERN virtual void on_session_opened(event &e); - PN_CPP_EXTERN virtual void on_session_opening(event &e); - PN_CPP_EXTERN virtual void on_link_closed(event &e); - PN_CPP_EXTERN virtual void on_link_closing(event &e); - PN_CPP_EXTERN virtual void on_link_error(event &e); - PN_CPP_EXTERN virtual void on_link_local_open(event &e); PN_CPP_EXTERN virtual void on_link_remote_open(event &e); PN_CPP_EXTERN virtual void on_link_remote_close(event &e); - PN_CPP_EXTERN virtual void on_link_opened(event &e); - PN_CPP_EXTERN virtual void on_link_opening(event &e); PN_CPP_EXTERN virtual void on_transport_tail_closed(event &e); + + PN_CPP_EXTERN virtual void on_connection_close(event &e); + PN_CPP_EXTERN virtual void on_connection_error(event &e); + PN_CPP_EXTERN virtual void on_connection_open(event &e); + PN_CPP_EXTERN virtual void on_session_close(event &e); + PN_CPP_EXTERN virtual void on_session_error(event &e); + PN_CPP_EXTERN virtual void on_session_open(event &e); + PN_CPP_EXTERN virtual void on_link_close(event &e); + PN_CPP_EXTERN virtual void on_link_error(event &e); + PN_CPP_EXTERN virtual void on_link_open(event &e); private: messaging_handler &delegate_; // The handler for generated messaging_event's }; http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/include/proton/messaging_handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp index 8fac665..9ec0f0d 100644 --- a/proton-c/bindings/cpp/include/proton/messaging_handler.hpp +++ b/proton-c/bindings/cpp/include/proton/messaging_handler.hpp @@ -51,34 +51,33 @@ class messaging_handler : public proton_handler ///@name Over-ride these member functions to handle events ///@{ - PN_CPP_EXTERN virtual void on_accepted(event &e); - PN_CPP_EXTERN virtual void on_connection_closed(event &e); - PN_CPP_EXTERN virtual void on_connection_closing(event &e); - PN_CPP_EXTERN virtual void on_connection_error(event &e); - PN_CPP_EXTERN virtual void on_connection_opening(event &e); - PN_CPP_EXTERN virtual void on_connection_opened(event &e); - PN_CPP_EXTERN virtual void on_disconnected(event &e); - PN_CPP_EXTERN virtual void on_link_closed(event &e); - PN_CPP_EXTERN virtual void on_link_closing(event &e); - PN_CPP_EXTERN virtual void on_link_error(event &e); - PN_CPP_EXTERN virtual void on_link_opened(event &e); - PN_CPP_EXTERN virtual void on_link_opening(event &e); + PN_CPP_EXTERN virtual void on_start(event &e); PN_CPP_EXTERN virtual void on_message(event &e); - PN_CPP_EXTERN virtual void on_rejected(event &e); - PN_CPP_EXTERN virtual void on_released(event &e); PN_CPP_EXTERN virtual void on_sendable(event &e); - PN_CPP_EXTERN virtual void on_session_closed(event &e); - PN_CPP_EXTERN virtual void on_session_closing(event &e); + PN_CPP_EXTERN virtual void on_disconnect(event &e); + + PN_CPP_EXTERN virtual void on_connection_open(event &e); + PN_CPP_EXTERN virtual void on_connection_close(event &e); + PN_CPP_EXTERN virtual void on_connection_error(event &e); + + PN_CPP_EXTERN virtual void on_session_open(event &e); + PN_CPP_EXTERN virtual void on_session_close(event &e); PN_CPP_EXTERN virtual void on_session_error(event &e); - PN_CPP_EXTERN virtual void on_session_opened(event &e); - PN_CPP_EXTERN virtual void on_session_opening(event &e); - PN_CPP_EXTERN virtual void on_settled(event &e); - PN_CPP_EXTERN virtual void on_start(event &e); + + PN_CPP_EXTERN virtual void on_link_open(event &e); + PN_CPP_EXTERN virtual void on_link_close(event &e); + PN_CPP_EXTERN virtual void on_link_error(event &e); + + PN_CPP_EXTERN virtual void on_delivery_accept(event &e); + PN_CPP_EXTERN virtual void on_delivery_reject(event &e); + PN_CPP_EXTERN virtual void on_delivery_release(event &e); + PN_CPP_EXTERN virtual void on_delivery_settle(event &e); + + PN_CPP_EXTERN virtual void on_transaction_declare(event &e); + PN_CPP_EXTERN virtual void on_transaction_commit(event &e); + PN_CPP_EXTERN virtual void on_transaction_abort(event &e); + PN_CPP_EXTERN virtual void on_timer(event &e); - PN_CPP_EXTERN virtual void on_transaction_aborted(event &e); - PN_CPP_EXTERN virtual void on_transaction_committed(event &e); - PN_CPP_EXTERN virtual void on_transaction_declared(event &e); - PN_CPP_EXTERN virtual void on_transport_closed(event &e); ///@} private: http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_adapter.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp index c91df35..cf90754 100644 --- a/proton-c/bindings/cpp/src/messaging_adapter.cpp +++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp @@ -92,29 +92,29 @@ void messaging_adapter::on_delivery(event &e) { } } else if (dlv.updated() && dlv.settled()) { - messaging_event mevent(messaging_event::SETTLED, *pe); - delegate_.on_settled(mevent); + messaging_event mevent(messaging_event::DELIVERY_SETTLE, *pe); + delegate_.on_delivery_settle(mevent); } } else { // sender if (dlv.updated()) { amqp_ulong rstate = dlv.remote_state(); if (rstate == PN_ACCEPTED) { - messaging_event mevent(messaging_event::ACCEPTED, *pe); - delegate_.on_accepted(mevent); + messaging_event mevent(messaging_event::DELIVERY_ACCEPT, *pe); + delegate_.on_delivery_accept(mevent); } else if (rstate == PN_REJECTED) { - messaging_event mevent(messaging_event::REJECTED, *pe); - delegate_.on_rejected(mevent); + messaging_event mevent(messaging_event::DELIVERY_REJECT, *pe); + delegate_.on_delivery_reject(mevent); } else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) { - messaging_event mevent(messaging_event::RELEASED, *pe); - delegate_.on_released(mevent); + messaging_event mevent(messaging_event::DELIVERY_RELEASE, *pe); + delegate_.on_delivery_release(mevent); } if (dlv.settled()) { - messaging_event mevent(messaging_event::SETTLED, *pe); - delegate_.on_settled(mevent); + messaging_event mevent(messaging_event::DELIVERY_SETTLE, *pe); + delegate_.on_delivery_settle(mevent); } if (auto_settle_) dlv.settle(); @@ -133,14 +133,6 @@ bool is_local_unititialised(pn_state_t state) { return state & PN_LOCAL_UNINIT; } -bool is_local_closed(pn_state_t state) { - return state & PN_LOCAL_CLOSED; -} - -bool is_remote_open(pn_state_t state) { - return state & PN_REMOTE_ACTIVE; -} - } // namespace void messaging_adapter::on_link_remote_close(event &e) { @@ -148,18 +140,13 @@ void messaging_adapter::on_link_remote_close(event &e) { if (pe) { pn_event_t *cevent = pe->pn_event(); pn_link_t *lnk = pn_event_link(cevent); - pn_state_t state = pn_link_state(lnk); if (pn_condition_is_set(pn_link_remote_condition(lnk))) { messaging_event mevent(messaging_event::LINK_ERROR, *pe); on_link_error(mevent); } - else if (is_local_closed(state)) { - messaging_event mevent(messaging_event::LINK_CLOSED, *pe); - on_link_closed(mevent); - } else { - messaging_event mevent(messaging_event::LINK_CLOSING, *pe); - on_link_closing(mevent); + messaging_event mevent(messaging_event::LINK_CLOSE, *pe); + on_link_close(mevent); } pn_link_close(lnk); } @@ -170,18 +157,13 @@ void messaging_adapter::on_session_remote_close(event &e) { if (pe) { pn_event_t *cevent = pe->pn_event(); pn_session_t *session = pn_event_session(cevent); - pn_state_t state = pn_session_state(session); if (pn_condition_is_set(pn_session_remote_condition(session))) { messaging_event mevent(messaging_event::SESSION_ERROR, *pe); on_session_error(mevent); } - else if (is_local_closed(state)) { - messaging_event mevent(messaging_event::SESSION_CLOSED, *pe); - on_session_closed(mevent); - } else { - messaging_event mevent(messaging_event::SESSION_CLOSING, *pe); - on_session_closing(mevent); + messaging_event mevent(messaging_event::SESSION_CLOSE, *pe); + on_session_close(mevent); } pn_session_close(session); } @@ -192,99 +174,49 @@ void messaging_adapter::on_connection_remote_close(event &e) { if (pe) { pn_event_t *cevent = pe->pn_event(); pn_connection_t *connection = pn_event_connection(cevent); - pn_state_t state = pn_connection_state(connection); if (pn_condition_is_set(pn_connection_remote_condition(connection))) { messaging_event mevent(messaging_event::CONNECTION_ERROR, *pe); on_connection_error(mevent); } - else if (is_local_closed(state)) { - messaging_event mevent(messaging_event::CONNECTION_CLOSED, *pe); - on_connection_closed(mevent); - } else { - messaging_event mevent(messaging_event::CONNECTION_CLOSING, *pe); - on_connection_closing(mevent); + messaging_event mevent(messaging_event::CONNECTION_CLOSE, *pe); + on_connection_close(mevent); } pn_connection_close(connection); } } -void messaging_adapter::on_connection_local_open(event &e) { - proton_event *pe = dynamic_cast<proton_event*>(&e); - if (pe) { - pn_connection_t *connection = pn_event_connection(pe->pn_event()); - if (is_remote_open(pn_connection_state(connection))) { - messaging_event mevent(messaging_event::CONNECTION_OPENED, *pe); - on_connection_opened(mevent); - } - } -} - void messaging_adapter::on_connection_remote_open(event &e) { proton_event *pe = dynamic_cast<proton_event*>(&e); if (pe) { + messaging_event mevent(messaging_event::CONNECTION_OPEN, *pe); + on_connection_open(mevent); pn_connection_t *connection = pn_event_connection(pe->pn_event()); - if (is_local_open(pn_connection_state(connection))) { - messaging_event mevent(messaging_event::CONNECTION_OPENED, *pe); - on_connection_opened(mevent); - } - else if (is_local_unititialised(pn_connection_state(connection))) { - messaging_event mevent(messaging_event::CONNECTION_OPENING, *pe); - on_connection_opening(mevent); + if (!is_local_open(pn_connection_state(connection)) && is_local_unititialised(pn_connection_state(connection))) { pn_connection_open(connection); } } } -void messaging_adapter::on_session_local_open(event &e) { - proton_event *pe = dynamic_cast<proton_event*>(&e); - if (pe) { - pn_session_t *session = pn_event_session(pe->pn_event()); - if (is_remote_open(pn_session_state(session))) { - messaging_event mevent(messaging_event::SESSION_OPENED, *pe); - on_session_opened(mevent); - } - } -} - void messaging_adapter::on_session_remote_open(event &e) { proton_event *pe = dynamic_cast<proton_event*>(&e); if (pe) { + messaging_event mevent(messaging_event::SESSION_OPEN, *pe); + on_session_open(mevent); pn_session_t *session = pn_event_session(pe->pn_event()); - if (is_local_open(pn_session_state(session))) { - messaging_event mevent(messaging_event::SESSION_OPENED, *pe); - on_session_opened(mevent); - } - else if (is_local_unititialised(pn_session_state(session))) { - messaging_event mevent(messaging_event::SESSION_OPENING, *pe); - on_session_opening(mevent); + if (!is_local_open(pn_session_state(session)) && is_local_unititialised(pn_session_state(session))) { pn_session_open(session); } } } -void messaging_adapter::on_link_local_open(event &e) { - proton_event *pe = dynamic_cast<proton_event*>(&e); - if (pe) { - pn_link_t *link = pn_event_link(pe->pn_event()); - if (is_remote_open(pn_link_state(link))) { - messaging_event mevent(messaging_event::LINK_OPENED, *pe); - on_link_opened(mevent); - } - } -} - void messaging_adapter::on_link_remote_open(event &e) { proton_event *pe = dynamic_cast<proton_event*>(&e); if (pe) { + messaging_event mevent(messaging_event::LINK_OPEN, *pe); + on_link_open(mevent); pn_link_t *link = pn_event_link(pe->pn_event()); - if (is_local_open(pn_link_state(link))) { - messaging_event mevent(messaging_event::LINK_OPENED, *pe); - on_link_opened(mevent); - } - else if (is_local_unititialised(pn_link_state(link))) { - messaging_event mevent(messaging_event::LINK_OPENING, *pe); - on_link_opening(mevent); + if (!is_local_open(pn_link_state(link)) && is_local_unititialised(pn_link_state(link))) { pn_link_open(link); } } @@ -295,35 +227,23 @@ void messaging_adapter::on_transport_tail_closed(event &e) { if (pe) { pn_connection_t *conn = pn_event_connection(pe->pn_event()); if (conn && is_local_open(pn_connection_state(conn))) { - messaging_event mevent(messaging_event::DISCONNECTED, *pe); - delegate_.on_disconnected(mevent); + messaging_event mevent(messaging_event::DISCONNECT, *pe); + delegate_.on_disconnect(mevent); } } } -void messaging_adapter::on_connection_opened(event &e) { - delegate_.on_connection_opened(e); -} - -void messaging_adapter::on_session_opened(event &e) { - delegate_.on_session_opened(e); +void messaging_adapter::on_connection_open(event &e) { + delegate_.on_connection_open(e); } -void messaging_adapter::on_link_opened(event &e) { - delegate_.on_link_opened(e); +void messaging_adapter::on_session_open(event &e) { + delegate_.on_session_open(e); } -void messaging_adapter::on_connection_opening(event &e) { - delegate_.on_connection_opening(e); -} - -void messaging_adapter::on_session_opening(event &e) { - delegate_.on_session_opening(e); -} - -void messaging_adapter::on_link_opening(event &e) { - delegate_.on_link_opening(e); +void messaging_adapter::on_link_open(event &e) { + delegate_.on_link_open(e); } void messaging_adapter::on_connection_error(event &e) { @@ -338,32 +258,20 @@ void messaging_adapter::on_link_error(event &e) { delegate_.on_link_error(e); } -void messaging_adapter::on_connection_closed(event &e) { - delegate_.on_connection_closed(e); -} - -void messaging_adapter::on_session_closed(event &e) { - delegate_.on_session_closed(e); -} - -void messaging_adapter::on_link_closed(event &e) { - delegate_.on_link_closed(e); -} - -void messaging_adapter::on_connection_closing(event &e) { - delegate_.on_connection_closing(e); +void messaging_adapter::on_connection_close(event &e) { + delegate_.on_connection_close(e); if (peer_close_iserror_) on_connection_error(e); } -void messaging_adapter::on_session_closing(event &e) { - delegate_.on_session_closing(e); +void messaging_adapter::on_session_close(event &e) { + delegate_.on_session_close(e); if (peer_close_iserror_) on_session_error(e); } -void messaging_adapter::on_link_closing(event &e) { - delegate_.on_link_closing(e); +void messaging_adapter::on_link_close(event &e) { + delegate_.on_link_close(e); if (peer_close_iserror_) on_link_error(e); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_event.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_event.cpp b/proton-c/bindings/cpp/src/messaging_event.cpp index 4b1e781..b360299 100644 --- a/proton-c/bindings/cpp/src/messaging_event.cpp +++ b/proton-c/bindings/cpp/src/messaging_event.cpp @@ -111,33 +111,34 @@ void messaging_event::dispatch(handler &h) { if (handler) { switch(type_) { - case messaging_event::START: handler->on_start(*this); break; - case messaging_event::SENDABLE: handler->on_sendable(*this); break; - case messaging_event::MESSAGE: handler->on_message(*this); break; - case messaging_event::ACCEPTED: handler->on_accepted(*this); break; - case messaging_event::REJECTED: handler->on_rejected(*this); break; - case messaging_event::RELEASED: handler->on_released(*this); break; - case messaging_event::SETTLED: handler->on_settled(*this); break; - - case messaging_event::CONNECTION_CLOSING: handler->on_connection_closing(*this); break; - case messaging_event::CONNECTION_CLOSED: handler->on_connection_closed(*this); break; - case messaging_event::CONNECTION_ERROR: handler->on_connection_error(*this); break; - case messaging_event::CONNECTION_OPENING: handler->on_connection_opening(*this); break; - case messaging_event::CONNECTION_OPENED: handler->on_connection_opened(*this); break; - - case messaging_event::LINK_CLOSED: handler->on_link_closed(*this); break; - case messaging_event::LINK_CLOSING: handler->on_link_closing(*this); break; - case messaging_event::LINK_ERROR: handler->on_link_error(*this); break; - case messaging_event::LINK_OPENING: handler->on_link_opening(*this); break; - case messaging_event::LINK_OPENED: handler->on_link_opened(*this); break; - - case messaging_event::SESSION_CLOSED: handler->on_session_closed(*this); break; - case messaging_event::SESSION_CLOSING: handler->on_session_closing(*this); break; - case messaging_event::SESSION_ERROR: handler->on_session_error(*this); break; - case messaging_event::SESSION_OPENING: handler->on_session_opening(*this); break; - case messaging_event::SESSION_OPENED: handler->on_session_opened(*this); break; - - case messaging_event::TRANSPORT_CLOSED: handler->on_transport_closed(*this); break; + case messaging_event::START: handler->on_start(*this); break; + case messaging_event::SENDABLE: handler->on_sendable(*this); break; + case messaging_event::MESSAGE: handler->on_message(*this); break; + case messaging_event::DISCONNECT: handler->on_disconnect(*this); break; + + case messaging_event::CONNECTION_CLOSE: handler->on_connection_close(*this); break; + case messaging_event::CONNECTION_ERROR: handler->on_connection_error(*this); break; + case messaging_event::CONNECTION_OPEN: handler->on_connection_open(*this); break; + + case messaging_event::SESSION_CLOSE: handler->on_session_close(*this); break; + case messaging_event::SESSION_ERROR: handler->on_session_error(*this); break; + case messaging_event::SESSION_OPEN: handler->on_session_open(*this); break; + + case messaging_event::LINK_CLOSE: handler->on_link_close(*this); break; + case messaging_event::LINK_ERROR: handler->on_link_error(*this); break; + case messaging_event::LINK_OPEN: handler->on_link_open(*this); break; + + case messaging_event::DELIVERY_ACCEPT: handler->on_delivery_accept(*this); break; + case messaging_event::DELIVERY_REJECT: handler->on_delivery_reject(*this); break; + case messaging_event::DELIVERY_RELEASE: handler->on_delivery_release(*this); break; + case messaging_event::DELIVERY_SETTLE: handler->on_delivery_settle(*this); break; + + case messaging_event::TRANSACTION_DECLARE: handler->on_transaction_declare(*this); break; + case messaging_event::TRANSACTION_COMMIT: handler->on_transaction_commit(*this); break; + case messaging_event::TRANSACTION_ABORT: handler->on_transaction_abort(*this); break; + + case messaging_event::TIMER: handler->on_timer(*this); break; + default: throw error(MSG("Unknown messaging event type " << type_)); break; @@ -155,36 +156,27 @@ void messaging_event::dispatch(handler &h) { std::string messaging_event::name() const { switch (type()) { case PROTON: return pn_event_type_name(pn_event_type_t(proton_event::type())); - case ACCEPTED: return "ACCEPTED"; - case COMMIT: return "COMMIT"; - case CONNECTION_CLOSED: return "CONNECTION_CLOSED"; - case CONNECTION_CLOSING: return "CONNECTION_CLOSING"; + case START: return "START"; + case MESSAGE: return "MESSAGE"; + case SENDABLE: return "SENDABLE"; + case DISCONNECT: return "DISCONNECT"; + case DELIVERY_ACCEPT: return "DELIVERY_ACCEPT"; + case DELIVERY_REJECT: return "DELIVERY_REJECT"; + case DELIVERY_RELEASE: return "DELIVERY_RELEASE"; + case DELIVERY_SETTLE: return "DELIVERY_SETTLE"; + case CONNECTION_CLOSE: return "CONNECTION_CLOSE"; case CONNECTION_ERROR: return "CONNECTION_ERROR"; - case CONNECTION_OPENED: return "CONNECTION_OPENED"; - case CONNECTION_OPENING: return "CONNECTION_OPENING"; - case DISCONNECTED: return "DISCONNECTED"; - case LINK_CLOSED: return "LINK_CLOSED"; - case LINK_CLOSING: return "LINK_CLOSING"; - case LINK_OPENED: return "LINK_OPENED"; - case LINK_OPENING: return "LINK_OPENING"; - case LINK_ERROR: return "LINK_ERROR"; - case MESSAGE: return "MESSAGE"; - case QUIT: return "QUIT"; - case REJECTED: return "REJECTED"; - case RELEASED: return "RELEASED"; - case SENDABLE: return "SENDABLE"; - case SESSION_CLOSED: return "SESSION_CLOSED"; - case SESSION_CLOSING: return "SESSION_CLOSING"; - case SESSION_OPENED: return "SESSION_OPENED"; - case SESSION_OPENING: return "SESSION_OPENING"; - case SESSION_ERROR: return "SESSION_ERROR"; - case SETTLED: return "SETTLED"; - case START: return "START"; - case TIMER: return "TIMER"; - case TRANSACTION_ABORTED: return "TRANSACTION_ABORTED"; - case TRANSACTION_COMMITTED: return "TRANSACTION_COMMITTED"; - case TRANSACTION_DECLARED: return "TRANSACTION_DECLARED"; - case TRANSPORT_CLOSED: return "TRANSPORT_CLOSED"; + case CONNECTION_OPEN: return "CONNECTION_OPEN"; + case LINK_CLOSE: return "LINK_CLOSE"; + case LINK_OPEN: return "LINK_OPEN"; + case LINK_ERROR: return "LINK_ERROR"; + case SESSION_CLOSE: return "SESSION_CLOSE"; + case SESSION_OPEN: return "SESSION_OPEN"; + case SESSION_ERROR: return "SESSION_ERROR"; + case TRANSACTION_ABORT: return "TRANSACTION_ABORT"; + case TRANSACTION_COMMIT: return "TRANSACTION_COMMIT"; + case TRANSACTION_DECLARE: return "TRANSACTION_DECLARE"; + case TIMER: return "TIMER"; default: return "UNKNOWN"; } } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_event.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_event.hpp b/proton-c/bindings/cpp/src/messaging_event.hpp index 2c90c0b..13d2da3 100644 --- a/proton-c/bindings/cpp/src/messaging_event.hpp +++ b/proton-c/bindings/cpp/src/messaging_event.hpp @@ -44,36 +44,27 @@ class messaging_event : public proton_event /** Event types for a messaging_handler */ enum event_type { PROTON = 0, // Wrapped pn_event_t - ACCEPTED, - COMMIT, - CONNECTION_CLOSED, - CONNECTION_CLOSING, - CONNECTION_ERROR, - CONNECTION_OPENED, - CONNECTION_OPENING, - DISCONNECTED, - LINK_CLOSED, - LINK_CLOSING, - LINK_OPENED, - LINK_OPENING, - LINK_ERROR, + START, MESSAGE, - QUIT, - REJECTED, - RELEASED, SENDABLE, - SESSION_CLOSED, - SESSION_CLOSING, - SESSION_OPENED, - SESSION_OPENING, + DISCONNECT, + CONNECTION_OPEN, + CONNECTION_CLOSE, + CONNECTION_ERROR, + LINK_OPEN, + LINK_CLOSE, + LINK_ERROR, + SESSION_OPEN, + SESSION_CLOSE, SESSION_ERROR, - SETTLED, - START, - TIMER, - TRANSACTION_ABORTED, - TRANSACTION_COMMITTED, - TRANSACTION_DECLARED, - TRANSPORT_CLOSED + DELIVERY_ACCEPT, + DELIVERY_REJECT, + DELIVERY_RELEASE, + DELIVERY_SETTLE, + TRANSACTION_DECLARE, + TRANSACTION_COMMIT, + TRANSACTION_ABORT, + TIMER }; messaging_event(pn_event_t *, proton_event::event_type, class event_loop *); http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c12eae18/proton-c/bindings/cpp/src/messaging_handler.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/messaging_handler.cpp b/proton-c/bindings/cpp/src/messaging_handler.cpp index 9496440..2f7383f 100644 --- a/proton-c/bindings/cpp/src/messaging_handler.cpp +++ b/proton-c/bindings/cpp/src/messaging_handler.cpp @@ -81,33 +81,26 @@ void messaging_handler::create_helpers() { messaging_handler::~messaging_handler(){} -void messaging_handler::on_accepted(event &e) { on_unhandled(e); } -void messaging_handler::on_connection_closed(event &e) { on_unhandled(e); } -void messaging_handler::on_connection_closing(event &e) { on_unhandled(e); } +void messaging_handler::on_delivery_accept(event &e) { on_unhandled(e); } +void messaging_handler::on_connection_close(event &e) { on_unhandled(e); } void messaging_handler::on_connection_error(event &e) { on_unhandled(e); } -void messaging_handler::on_connection_opened(event &e) { on_unhandled(e); } -void messaging_handler::on_connection_opening(event &e) { on_unhandled(e); } -void messaging_handler::on_disconnected(event &e) { on_unhandled(e); } -void messaging_handler::on_link_closed(event &e) { on_unhandled(e); } -void messaging_handler::on_link_closing(event &e) { on_unhandled(e); } +void messaging_handler::on_connection_open(event &e) { on_unhandled(e); } +void messaging_handler::on_disconnect(event &e) { on_unhandled(e); } +void messaging_handler::on_link_close(event &e) { on_unhandled(e); } void messaging_handler::on_link_error(event &e) { on_unhandled(e); } -void messaging_handler::on_link_opened(event &e) { on_unhandled(e); } -void messaging_handler::on_link_opening(event &e) { on_unhandled(e); } +void messaging_handler::on_link_open(event &e) { on_unhandled(e); } void messaging_handler::on_message(event &e) { on_unhandled(e); } -void messaging_handler::on_rejected(event &e) { on_unhandled(e); } -void messaging_handler::on_released(event &e) { on_unhandled(e); } +void messaging_handler::on_delivery_reject(event &e) { on_unhandled(e); } +void messaging_handler::on_delivery_release(event &e) { on_unhandled(e); } void messaging_handler::on_sendable(event &e) { on_unhandled(e); } -void messaging_handler::on_session_closed(event &e) { on_unhandled(e); } -void messaging_handler::on_session_closing(event &e) { on_unhandled(e); } +void messaging_handler::on_session_close(event &e) { on_unhandled(e); } void messaging_handler::on_session_error(event &e) { on_unhandled(e); } -void messaging_handler::on_session_opened(event &e) { on_unhandled(e); } -void messaging_handler::on_session_opening(event &e) { on_unhandled(e); } -void messaging_handler::on_settled(event &e) { on_unhandled(e); } +void messaging_handler::on_session_open(event &e) { on_unhandled(e); } +void messaging_handler::on_delivery_settle(event &e) { on_unhandled(e); } void messaging_handler::on_start(event &e) { on_unhandled(e); } void messaging_handler::on_timer(event &e) { on_unhandled(e); } -void messaging_handler::on_transaction_aborted(event &e) { on_unhandled(e); } -void messaging_handler::on_transaction_committed(event &e) { on_unhandled(e); } -void messaging_handler::on_transaction_declared(event &e) { on_unhandled(e); } -void messaging_handler::on_transport_closed(event &e) { on_unhandled(e); } +void messaging_handler::on_transaction_abort(event &e) { on_unhandled(e); } +void messaging_handler::on_transaction_commit(event &e) { on_unhandled(e); } +void messaging_handler::on_transaction_declare(event &e) { on_unhandled(e); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
