00001 #ifndef QPID_BROKER_PREVIEWSESSIONHANDLER_H
00002 #define QPID_BROKER_PREVIEWSESSIONHANDLER_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/ChannelHandler.h"
00031 #include "SessionContext.h"
00032
00033 #include <boost/noncopyable.hpp>
00034
00035 namespace qpid {
00036 namespace broker {
00037
00038 class PreviewConnection;
00039 class PreviewSessionState;
00040
00046 class PreviewSessionHandler : public framing::AMQP_ServerOperations::SessionHandler,
00047 public framing::AMQP_ClientOperations::SessionHandler,
00048 public framing::FrameHandler::InOutHandler,
00049 private boost::noncopyable
00050 {
00051 public:
00052 PreviewSessionHandler(PreviewConnection&, framing::ChannelId);
00053 ~PreviewSessionHandler();
00054
00056 PreviewSessionState* getSession() { return session.get(); }
00057 const PreviewSessionState* getSession() const { return session.get(); }
00058
00059 framing::ChannelId getChannel() const { return channel.get(); }
00060
00061 ConnectionState& getConnection();
00062 const ConnectionState& getConnection() const;
00063
00064 framing::AMQP_ClientProxy& getProxy() { return proxy; }
00065 const framing::AMQP_ClientProxy& getProxy() const { return proxy; }
00066
00067
00068 void localSuspend();
00069 void detach() { localSuspend(); }
00070
00071 protected:
00072 void handleIn(framing::AMQFrame&);
00073 void handleOut(framing::AMQFrame&);
00074
00075 private:
00077 void open(uint32_t detachedLifetime);
00078 void flow(bool active);
00079 void flowOk(bool active);
00080 void close();
00081 void closed(uint16_t replyCode, const std::string& replyText);
00082 void resume(const framing::Uuid& sessionId);
00083 void suspend();
00084 void ack(uint32_t cumulativeSeenMark,
00085 const framing::SequenceNumberSet& seenFrameSet);
00086 void highWaterMark(uint32_t lastSentMark);
00087 void solicitAck();
00088
00089
00090 void attached(const framing::Uuid& sessionId, uint32_t detachedLifetime);
00091 void detached();
00092
00093
00094 void assertAttached(const char* method) const;
00095 void assertActive(const char* method) const;
00096 void assertClosed(const char* method) const;
00097
00098
00099 PreviewConnection& connection;
00100 framing::ChannelHandler channel;
00101 framing::AMQP_ClientProxy proxy;
00102 framing::AMQP_ClientProxy::Session peerSession;
00103 bool ignoring;
00104 std::auto_ptr<PreviewSessionState> session;
00105 };
00106
00107 }}
00108
00109
00110
00111 #endif