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 "qpid/framing/FrameHandler.h"
00028 #include "qpid/sys/Mutex.h"
00029 #include "qpid/sys/ShutdownHandler.h"
00030 #include "qpid/sys/TimeoutHandler.h"
00031
00032 #include <map>
00033 #include <boost/shared_ptr.hpp>
00034 #include <boost/weak_ptr.hpp>
00035 #include <boost/scoped_ptr.hpp>
00036 #include <boost/enable_shared_from_this.hpp>
00037
00038 namespace qpid {
00039 namespace client {
00040
00041 class Connector;
00042 class ConnectionSettings;
00043 class SessionImpl;
00044
00045 class ConnectionImpl : public Bounds,
00046 public framing::FrameHandler,
00047 public sys::TimeoutHandler,
00048 public sys::ShutdownHandler,
00049 public boost::enable_shared_from_this<ConnectionImpl>
00050
00051 {
00052 typedef std::map<uint16_t, boost::weak_ptr<SessionImpl> > SessionMap;
00053
00054 SessionMap sessions;
00055 ConnectionHandler handler;
00056 boost::scoped_ptr<Connector> connector;
00057 framing::ProtocolVersion version;
00058 sys::Mutex lock;
00059
00060 template <class F> void closeInternal(const F&);
00061
00062 void incoming(framing::AMQFrame& frame);
00063 void closed(uint16_t, const std::string&);
00064 void idleOut();
00065 void idleIn();
00066 void shutdown();
00067
00068 public:
00069 ConnectionImpl(framing::ProtocolVersion version, const ConnectionSettings& settings);
00070 ~ConnectionImpl();
00071
00072 void open(const std::string& host, int port);
00073 bool isOpen() const;
00074
00075 void addSession(const boost::shared_ptr<SessionImpl>&);
00076
00077 void close();
00078 void handle(framing::AMQFrame& frame);
00079 void erase(uint16_t channel);
00080
00081 const ConnectionSettings& getNegotiatedSettings();
00082 };
00083
00084 }}
00085
00086
00087 #endif