00001 #ifndef QPID_AMQP_0_10_SESSIONHANDLER_H
00002 #define QPID_AMQP_0_10_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/ChannelHandler.h"
00026 #include "qpid/framing/AMQP_AllProxy.h"
00027 #include "qpid/framing/AMQP_AllOperations.h"
00028
00029 namespace qpid {
00030
00031 class SessionState;
00032
00033 namespace amqp_0_10 {
00034
00042 class SessionHandler : public framing::AMQP_AllOperations::SessionHandler,
00043 public framing::FrameHandler::InOutHandler
00044 {
00045 public:
00046 typedef framing::AMQP_AllProxy::Session Peer;
00047
00048 SessionHandler();
00049 SessionHandler(framing::FrameHandler& out, uint16_t channel);
00050 ~SessionHandler();
00051
00052 void setChannel(uint16_t ch) { channel = ch; }
00053 uint16_t getChannel() const { return channel.get(); }
00054
00055 void setOutHandler(framing::FrameHandler& h) { channel.next = &h; }
00056
00057 virtual SessionState* getState() = 0;
00058 virtual framing::FrameHandler* getInHandler() = 0;
00059
00060
00061 void sendDetach();
00062 void sendCompletion();
00063 void sendAttach(bool force);
00064 void sendTimeout(uint32_t t);
00065 void sendFlush();
00066 void sendCommandPoint();
00067
00069 bool ready() const;
00070
00071
00072 void attach(const std::string& name, bool force);
00073 void attached(const std::string& name);
00074 void detach(const std::string& name);
00075 void detached(const std::string& name, uint8_t code);
00076
00077 void requestTimeout(uint32_t t);
00078 void timeout(uint32_t t);
00079
00080 void commandPoint(const framing::SequenceNumber& id, uint64_t offset);
00081 void expected(const framing::SequenceSet& commands, const framing::Array& fragments);
00082 void confirmed(const framing::SequenceSet& commands,const framing::Array& fragments);
00083 void completed(const framing::SequenceSet& commands, bool timelyReply);
00084 void knownCompleted(const framing::SequenceSet& commands);
00085 void flush(bool expected, bool confirmed, bool completed);
00086 void gap(const framing::SequenceSet& commands);
00087
00088 protected:
00089 virtual void invoke(const framing::AMQMethodBody& m);
00090
00091 virtual void setState(const std::string& sessionName, bool force) = 0;
00092 virtual void channelException(uint16_t code, const std::string& msg) = 0;
00093 virtual void connectionException(uint16_t code, const std::string& msg) = 0;
00094
00095
00096
00097 virtual void readyToSend() {}
00098 virtual void readyToReceive() {}
00099 virtual void handleDetach();
00100
00101 virtual void handleIn(framing::AMQFrame&);
00102 virtual void handleOut(framing::AMQFrame&);
00103
00104 void checkAttached();
00105 void checkName(const std::string& name);
00106
00107 framing::ChannelHandler channel;
00108 Peer peer;
00109 bool ignoring;
00110 bool sendReady, receiveReady;
00111
00112
00113 };
00114 }}
00115
00116 #endif