00001 #ifndef QPID_BROKER_SESSIONHANDLER_H
00002 #define QPID_BROKER_SESSIONHANDLER_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 "qpid/framing/FrameHandler.h"
00026 #include "qpid/framing/AMQP_ClientOperations.h"
00027 #include "qpid/framing/AMQP_ServerOperations.h"
00028 #include "qpid/framing/AMQP_ClientProxy.h"
00029 #include "qpid/framing/amqp_types.h"
00030 #include "qpid/framing/Array.h"
00031 #include "qpid/framing/ChannelHandler.h"
00032 #include "qpid/framing/SequenceNumber.h"
00033 #include "qpid/framing/SequenceSet.h"
00034
00035 #include <boost/noncopyable.hpp>
00036
00037 namespace qpid {
00038 namespace broker {
00039
00040 class Connection;
00041 class ConnectionState;
00042 class SessionState;
00043
00049 class SessionHandler : public framing::AMQP_ServerOperations::Session010Handler,
00050 public framing::FrameHandler::InOutHandler,
00051 private boost::noncopyable
00052 {
00053 public:
00054 SessionHandler(Connection&, framing::ChannelId);
00055 ~SessionHandler();
00056
00058 SessionState* getSession() { return session.get(); }
00059 const SessionState* getSession() const { return session.get(); }
00060
00061 framing::ChannelId getChannel() const { return channel.get(); }
00062
00063 ConnectionState& getConnection();
00064 const ConnectionState& getConnection() const;
00065
00066 framing::AMQP_ClientProxy& getProxy() { return proxy; }
00067 const framing::AMQP_ClientProxy& getProxy() const { return proxy; }
00068
00069
00070 void localSuspend();
00071 void detach() { localSuspend(); }
00072 void sendCompletion();
00073 void destroy();
00074
00075 protected:
00076 void handleIn(framing::AMQFrame&);
00077 void handleOut(framing::AMQFrame&);
00078
00079 private:
00080
00081 void attach(const std::string& name, bool force);
00082 void attached(const std::string& name);
00083 void detach(const std::string& name);
00084 void detached(const std::string& name, uint8_t code);
00085
00086 void requestTimeout(uint32_t t);
00087 void timeout(uint32_t t);
00088
00089 void commandPoint(const framing::SequenceNumber& id, uint64_t offset);
00090 void expected(const framing::SequenceSet& commands, const framing::Array& fragments);
00091 void confirmed(const framing::SequenceSet& commands,const framing::Array& fragments);
00092 void completed(const framing::SequenceSet& commands, bool timelyReply);
00093 void knownCompleted(const framing::SequenceSet& commands);
00094 void flush(bool expected, bool confirmed, bool completed);
00095 void gap(const framing::SequenceSet& commands);
00096
00097
00098 void commandPoint(uint32_t id, uint64_t offset) { commandPoint(framing::SequenceNumber(id), offset); }
00099
00100 void assertAttached(const char* method) const;
00101 void assertActive(const char* method) const;
00102 void assertClosed(const char* method) const;
00103
00104 Connection& connection;
00105 framing::ChannelHandler channel;
00106 framing::AMQP_ClientProxy proxy;
00107 framing::AMQP_ClientProxy::Session010 peerSession;
00108 bool ignoring;
00109 std::auto_ptr<SessionState> session;
00110 };
00111
00112 }}
00113
00114
00115
00116 #endif