Repository: qpid-proton Updated Branches: refs/heads/master 772fd54f2 -> 63658a41a
PROTON-1164: Add synthesised on_transport_open event - Event is generated just before on_connection_open Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/63658a41 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/63658a41 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/63658a41 Branch: refs/heads/master Commit: 63658a41a1ec6ee2725b130bafb45c05adbb2927 Parents: 772fd54 Author: Andrew Stitcher <[email protected]> Authored: Fri May 13 11:35:07 2016 +0100 Committer: Andrew Stitcher <[email protected]> Committed: Fri May 13 12:12:37 2016 +0100 ---------------------------------------------------------------------- examples/cpp/broker.hpp | 5 +++++ .../bindings/cpp/include/proton/handler.hpp | 21 ++++++++------------ proton-c/bindings/cpp/src/handler.cpp | 1 + proton-c/bindings/cpp/src/messaging_adapter.cpp | 4 +++- 4 files changed, 17 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63658a41/examples/cpp/broker.hpp ---------------------------------------------------------------------- diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp index 68a6354..45a2e13 100644 --- a/examples/cpp/broker.hpp +++ b/examples/cpp/broker.hpp @@ -31,6 +31,7 @@ #include "proton/delivery.hpp" #include "proton/handler.hpp" #include "proton/message.hpp" +#include "proton/sasl.hpp" #include "proton/sender.hpp" #include "proton/tracker.hpp" #include "proton/transport.hpp" @@ -159,6 +160,10 @@ class broker_handler : public proton::handler { public: broker_handler(queues& qs) : queues_(qs) {} + void on_transport_open(proton::transport &t) override { + std::cout << "Connection from user: " << t.sasl().user() << " (mechanism: " << t.sasl().mech() << ")" << std::endl; + } + void on_sender_open(proton::sender &sender) override { proton::source src(sender.source()); queue &q = src.dynamic() ? http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63658a41/proton-c/bindings/cpp/include/proton/handler.hpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/include/proton/handler.hpp b/proton-c/bindings/cpp/include/proton/handler.hpp index 3cc2759..d72e394 100644 --- a/proton-c/bindings/cpp/include/proton/handler.hpp +++ b/proton-c/bindings/cpp/include/proton/handler.hpp @@ -82,19 +82,6 @@ PN_CPP_CLASS_EXTERN handler /// A message can be sent. PN_CPP_EXTERN virtual void on_sendable(sender &s); - /// transport_open is not present because currently there is no specific - /// low level event to hang it from - you should put any initialisation code - /// that needs a transport into the conection_open event. - /// XXX Actually this makes me wonder if we shouldn't just introduce this event - /// XXX and call its handler immediately before on_connection_open, just for the - /// XXX symmetry of the API. - - /// The underlying network transport has closed. - PN_CPP_EXTERN virtual void on_transport_close(transport &t); - /// The underlying network transport has closed with an error - /// condition. - PN_CPP_EXTERN virtual void on_transport_error(transport &t); - /// Note that every ..._open event is paired with a ..._close event which can clean /// up any resources created by the ..._open handler. /// In particular this is still true if an error is reported with an ..._error event. @@ -102,6 +89,14 @@ PN_CPP_CLASS_EXTERN handler /// have to manage the resource clean up, but can just assume that the close event will /// be along in a minute to handle the clean up. + /// The underlying network transport is open + PN_CPP_EXTERN virtual void on_transport_open(transport &t); + /// The underlying network transport has closed. + PN_CPP_EXTERN virtual void on_transport_close(transport &t); + /// The underlying network transport has closed with an error + /// condition. + PN_CPP_EXTERN virtual void on_transport_error(transport &t); + /// The remote peer opened the connection. PN_CPP_EXTERN virtual void on_connection_open(connection &c); /// The remote peer closed the connection. http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63658a41/proton-c/bindings/cpp/src/handler.cpp ---------------------------------------------------------------------- diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp index 42f01a5..1f89225 100644 --- a/proton-c/bindings/cpp/src/handler.cpp +++ b/proton-c/bindings/cpp/src/handler.cpp @@ -44,6 +44,7 @@ void handler::on_message(delivery &, message &) {} void handler::on_sendable(sender &) {} void handler::on_transport_close(transport &) {} void handler::on_transport_error(transport &t) { on_error(t.error()); } +void handler::on_transport_open(transport &) {} void handler::on_connection_close(connection &) {} void handler::on_connection_error(connection &c) { on_error(c.error()); } void handler::on_connection_open(connection &) {} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/63658a41/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 1fe9bcd..b8a6e32 100644 --- a/proton-c/bindings/cpp/src/messaging_adapter.cpp +++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp @@ -225,7 +225,9 @@ void messaging_adapter::on_connection_remote_close(proton_event &pe) { void messaging_adapter::on_connection_remote_open(proton_event &pe) { pn_connection_t *conn = pn_event_connection(pe.pn_event()); - class connection c(make_wrapper(conn)); + connection c(make_wrapper(conn)); + transport t(make_wrapper(pn_event_transport(pe.pn_event()))); + delegate_.on_transport_open(t); delegate_.on_connection_open(c); if (!is_local_open(pn_connection_state(conn)) && is_local_unititialised(pn_connection_state(conn))) { pn_connection_open(conn); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
