00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _Connection_
00022 #define _Connection_
00023
00024 #include <sstream>
00025 #include <vector>
00026
00027 #include <boost/ptr_container/ptr_map.hpp>
00028
00029 #include "qpid/framing/AMQFrame.h"
00030 #include "qpid/framing/AMQP_ServerOperations.h"
00031 #include "qpid/framing/AMQP_ClientProxy.h"
00032 #include "qpid/sys/ConnectionOutputHandler.h"
00033 #include "qpid/sys/ConnectionInputHandler.h"
00034 #include "qpid/sys/TimeoutHandler.h"
00035 #include "qpid/framing/ProtocolVersion.h"
00036 #include "Broker.h"
00037 #include "qpid/Exception.h"
00038 #include "BrokerChannel.h"
00039
00040 namespace qpid {
00041 namespace broker {
00042
00043 class Channel;
00044
00045 class Connection : public sys::ConnectionInputHandler,
00046 public ConnectionToken
00047 {
00048 public:
00049 Connection(sys::ConnectionOutputHandler* out, Broker& broker);
00050
00052 Channel& getChannel(framing::ChannelId channel);
00053
00055 void closeChannel(framing::ChannelId channel);
00056
00058 void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
00059
00060 sys::ConnectionOutputHandler& getOutput() const { return *out; }
00061 framing::ProtocolVersion getVersion() const { return version; }
00062
00063 uint32_t getFrameMax() const { return framemax; }
00064 uint16_t getHeartbeat() const { return heartbeat; }
00065 uint32_t getTimeout() const { return timeout; }
00066 uint64_t getStagingThreshold() const { return stagingThreshold; }
00067
00068 void setFrameMax(uint32_t fm) { framemax = fm; }
00069 void setHeartbeat(uint16_t hb) { heartbeat = hb; }
00070
00077 Queue::shared_ptr getQueue(const string& name, uint16_t channel);
00078
00079 Broker& broker;
00080 std::vector<Queue::shared_ptr> exclusiveQueues;
00081
00082
00083 void received(framing::AMQFrame* frame);
00084 void initiated(const framing::ProtocolInitiation& header);
00085 void idleOut();
00086 void idleIn();
00087 void closed();
00088
00089 private:
00090 typedef boost::ptr_map<framing::ChannelId, Channel> ChannelMap;
00091
00092 typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00093 Exchange::shared_ptr findExchange(const string& name);
00094
00095 framing::ProtocolVersion version;
00096 ChannelMap channels;
00097 sys::ConnectionOutputHandler* out;
00098 uint32_t framemax;
00099 uint16_t heartbeat;
00100 framing::AMQP_ClientProxy::Connection* client;
00101 const uint32_t timeout;
00102 const uint64_t stagingThreshold;
00103
00104 };
00105
00106 }}
00107
00108 #endif