/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/broker/PreviewSessionHandler.h

00001 #ifndef QPID_BROKER_PREVIEWSESSIONHANDLER_H
00002 #define QPID_BROKER_PREVIEWSESSIONHANDLER_H
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  * 
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  * 
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
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     // Called by closing connection.
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     //extra methods required for assuming client role
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 }} // namespace qpid::broker
00108 
00109 
00110 
00111 #endif  

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7