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