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
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::SessionHandler,
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 void requestDetach();
00070 void handleDetach();
00071 void sendCompletion();
00072
00073 protected:
00074 void handleIn(framing::AMQFrame&);
00075 void handleOut(framing::AMQFrame&);
00076
00077 private:
00078
00079 void attach(const std::string& name, bool force);
00080 void attached(const std::string& name);
00081 void detach(const std::string& name);
00082 void detached(const std::string& name, uint8_t code);
00083
00084 void requestTimeout(uint32_t t);
00085 void timeout(uint32_t t);
00086
00087 void commandPoint(const framing::SequenceNumber& id, uint64_t offset);
00088 void expected(const framing::SequenceSet& commands, const framing::Array& fragments);
00089 void confirmed(const framing::SequenceSet& commands,const framing::Array& fragments);
00090 void completed(const framing::SequenceSet& commands, bool timelyReply);
00091 void knownCompleted(const framing::SequenceSet& commands);
00092 void flush(bool expected, bool confirmed, bool completed);
00093 void gap(const framing::SequenceSet& commands);
00094
00095 void assertAttached(const char* method) const;
00096 void assertActive(const char* method) const;
00097 void assertClosed(const char* method) const;
00098
00099 bool isValid(framing::AMQMethodBody*);
00100
00101 Connection& connection;
00102 framing::ChannelHandler channel;
00103 framing::AMQP_ClientProxy proxy;
00104 framing::AMQP_ClientProxy::Session peerSession;
00105 bool ignoring;
00106 std::auto_ptr<SessionState> session;
00107 std::string name;
00108 };
00109
00110 }}
00111
00112
00113
00114 #endif