00001 #ifndef QPID_BROKER_CONNECTION_H
00002 #define QPID_BROKER_CONNECTION_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <memory>
00026 #include <sstream>
00027 #include <vector>
00028
00029 #include <boost/ptr_container/ptr_map.hpp>
00030
00031 #include "qpid/framing/AMQFrame.h"
00032 #include "qpid/framing/AMQP_ServerOperations.h"
00033 #include "qpid/framing/AMQP_ClientProxy.h"
00034 #include "qpid/sys/AggregateOutput.h"
00035 #include "qpid/sys/ConnectionOutputHandler.h"
00036 #include "qpid/sys/ConnectionInputHandler.h"
00037 #include "qpid/sys/TimeoutHandler.h"
00038 #include "qpid/framing/ProtocolVersion.h"
00039 #include "Broker.h"
00040 #include "qpid/sys/Socket.h"
00041 #include "qpid/Exception.h"
00042 #include "ConnectionHandler.h"
00043 #include "ConnectionState.h"
00044 #include "SessionHandler.h"
00045 #include "qpid/management/Manageable.h"
00046 #include "qpid/management/Connection.h"
00047 #include "qpid/RefCounted.h"
00048
00049 #include <boost/ptr_container/ptr_map.hpp>
00050
00051 namespace qpid {
00052 namespace broker {
00053
00054 class LinkRegistry;
00055
00056 class Connection : public sys::ConnectionInputHandler,
00057 public ConnectionState,
00058 public RefCounted
00059 {
00060 public:
00061 Connection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false);
00062 ~Connection ();
00063
00065 SessionHandler& getChannel(framing::ChannelId channel);
00066
00068 void close(framing::ReplyCode code = 403,
00069 const string& text = string(),
00070 framing::ClassId classId = 0,
00071 framing::MethodId methodId = 0);
00072
00073
00074 void received(framing::AMQFrame& frame);
00075 void idleOut();
00076 void idleIn();
00077 bool hasOutput();
00078 bool doOutput();
00079 void closed();
00080
00081 void closeChannel(framing::ChannelId channel);
00082
00083
00084 management::ManagementObject* GetManagementObject (void) const;
00085 management::Manageable::status_t
00086 ManagementMethod (uint32_t methodId, management::Args& args);
00087
00088 void requestIOProcessing (boost::function0<void>);
00089 void recordFromServer (framing::AMQFrame& frame);
00090 void recordFromClient (framing::AMQFrame& frame);
00091 std::string getAuthMechanism();
00092 std::string getAuthCredentials();
00093 void notifyConnectionForced(const std::string& text);
00094 void setUserId(const string& uid);
00095
00096 private:
00097 typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
00098 typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00099
00100 ChannelMap channels;
00101 framing::AMQP_ClientProxy::Connection* client;
00102 ConnectionHandler adapter;
00103 bool isLink;
00104 bool mgmtClosing;
00105 const std::string mgmtId;
00106 boost::function0<void> ioCallback;
00107 management::Connection* mgmtObject;
00108 LinkRegistry& links;
00109 };
00110
00111 }}
00112
00113 #endif