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

00001 #ifndef QPID_BROKER_SESSIONHANDLER_H
00002 #define QPID_BROKER_SESSIONHANDLER_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/Array.h"
00031 #include "qpid/framing/ChannelHandler.h"
00032 #include "qpid/framing/SequenceNumber.h"
00033 #include "qpid/framing/SequenceSet.h"
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::Session010Handler,
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     // Called by closing connection.
00070     void localSuspend();
00071     void detach() { localSuspend(); }
00072     void sendCompletion();
00073     void destroy();
00074     
00075   protected:
00076     void handleIn(framing::AMQFrame&);
00077     void handleOut(framing::AMQFrame&);
00078     
00079   private:
00080     //new methods:
00081     void attach(const std::string& name, bool force);
00082     void attached(const std::string& name);
00083     void detach(const std::string& name);
00084     void detached(const std::string& name, uint8_t code);
00085 
00086     void requestTimeout(uint32_t t);
00087     void timeout(uint32_t t);
00088 
00089     void commandPoint(const framing::SequenceNumber& id, uint64_t offset);
00090     void expected(const framing::SequenceSet& commands, const framing::Array& fragments);
00091     void confirmed(const framing::SequenceSet& commands,const framing::Array& fragments);
00092     void completed(const framing::SequenceSet& commands, bool timelyReply);
00093     void knownCompleted(const framing::SequenceSet& commands);
00094     void flush(bool expected, bool confirmed, bool completed);
00095     void gap(const framing::SequenceSet& commands);    
00096 
00097     //hacks for old generator:
00098     void commandPoint(uint32_t id, uint64_t offset) { commandPoint(framing::SequenceNumber(id), offset); }
00099 
00100     void assertAttached(const char* method) const;
00101     void assertActive(const char* method) const;
00102     void assertClosed(const char* method) const;
00103 
00104     Connection& connection;
00105     framing::ChannelHandler channel;
00106     framing::AMQP_ClientProxy proxy;
00107     framing::AMQP_ClientProxy::Session010 peerSession;
00108     bool ignoring;
00109     std::auto_ptr<SessionState> session;
00110 };
00111 
00112 }} // namespace qpid::broker
00113 
00114 
00115 
00116 #endif  

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