diff options
-rw-r--r-- | cpp/src/qpid/broker/SessionManager.cpp | 6 | ||||
-rw-r--r-- | cpp/src/qpid/broker/SessionManager.h | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/cpp/src/qpid/broker/SessionManager.cpp b/cpp/src/qpid/broker/SessionManager.cpp index 1d5f9ebada..aadb2b9004 100644 --- a/cpp/src/qpid/broker/SessionManager.cpp +++ b/cpp/src/qpid/broker/SessionManager.cpp @@ -50,6 +50,8 @@ std::auto_ptr<SessionState> SessionManager::open( std::auto_ptr<SessionState> session( new SessionState(*this, h, timeout_, ack)); active.insert(session->getId()); + for_each(observers.begin(), observers.end(), + boost::bind(&Observer::opened, _1,boost::ref(*session))); return session; } @@ -102,4 +104,8 @@ void SessionManager::eraseExpired() { } } +void SessionManager::add(const intrusive_ptr<Observer>& o) { + observers.push_back(o); +} + }} // namespace qpid::broker diff --git a/cpp/src/qpid/broker/SessionManager.h b/cpp/src/qpid/broker/SessionManager.h index fa7262252d..bb61f5a8be 100644 --- a/cpp/src/qpid/broker/SessionManager.h +++ b/cpp/src/qpid/broker/SessionManager.h @@ -25,6 +25,7 @@ #include <qpid/framing/Uuid.h> #include <qpid/sys/Time.h> #include <qpid/sys/Mutex.h> +#include <qpid/RefCounted.h> #include <boost/noncopyable.hpp> #include <boost/ptr_container/ptr_vector.hpp> @@ -44,8 +45,17 @@ class SessionHandler; */ class SessionManager : private boost::noncopyable { public: + /** + * Observer notified of SessionManager events. + */ + struct Observer : public RefCounted { + virtual void opened(SessionState&) {} + }; + SessionManager(uint32_t ack); + ~SessionManager(); + /** Open a new active session, caller takes ownership */ std::auto_ptr<SessionState> open(SessionHandler& h, uint32_t timeout_); @@ -59,9 +69,13 @@ class SessionManager : private boost::noncopyable { */ std::auto_ptr<SessionState> resume(const framing::Uuid&); + /** Add an Observer. */ + void add(const intrusive_ptr<Observer>&); + private: typedef boost::ptr_vector<SessionState> Suspended; typedef std::set<framing::Uuid> Active; + typedef std::vector<intrusive_ptr<Observer> > Observers; void erase(const framing::Uuid&); void eraseExpired(); @@ -70,6 +84,7 @@ class SessionManager : private boost::noncopyable { Suspended suspended; Active active; uint32_t ack; + Observers observers; friend class SessionState; // removes deleted sessions from active set. }; |