00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _ConnectionImpl_
00023 #define _ConnectionImpl_
00024
00025 #include "Bounds.h"
00026 #include "ConnectionHandler.h"
00027 #include "Connector.h"
00028 #include "qpid/framing/FrameHandler.h"
00029 #include "qpid/sys/Mutex.h"
00030 #include "qpid/sys/ShutdownHandler.h"
00031 #include "qpid/sys/TimeoutHandler.h"
00032
00033 #include <map>
00034 #include <boost/shared_ptr.hpp>
00035 #include <boost/weak_ptr.hpp>
00036
00037 namespace qpid {
00038 namespace client {
00039
00040 class ConnectionSettings;
00041 class SessionImpl;
00042
00043 class ConnectionImpl : public Bounds,
00044 public framing::FrameHandler,
00045 public sys::TimeoutHandler,
00046 public sys::ShutdownHandler
00047
00048 {
00049 typedef std::map<uint16_t, boost::weak_ptr<SessionImpl> > SessionMap;
00050 typedef std::vector<boost::shared_ptr<SessionImpl> > SessionVector;
00051
00052 SessionMap sessions;
00053 ConnectionHandler handler;
00054 Connector connector;
00055 framing::ProtocolVersion version;
00056 sys::Mutex lock;
00057 bool isClosed;
00058 bool isClosing;
00059
00060 template <class F> void detachAll(const F&);
00061
00062 void open(const std::string& host, int port);
00063
00064 SessionVector closeInternal(const sys::Mutex::ScopedLock&);
00065 void incoming(framing::AMQFrame& frame);
00066 void closed(uint16_t, const std::string&);
00067 void idleOut();
00068 void idleIn();
00069 void shutdown();
00070 bool setClosing();
00071
00072 public:
00073 ConnectionImpl(framing::ProtocolVersion version, const ConnectionSettings& settings);
00074 ~ConnectionImpl();
00075
00076 void addSession(const boost::shared_ptr<SessionImpl>&);
00077
00078 void close();
00079 void handle(framing::AMQFrame& frame);
00080 void erase(uint16_t channel);
00081
00082 const ConnectionSettings& getNegotiatedSettings();
00083 };
00084
00085 }}
00086
00087
00088 #endif