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