diff options
author | Alan Conway <aconway@apache.org> | 2007-02-02 22:03:10 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-02-02 22:03:10 +0000 |
commit | b5c270f10496f522ef6a03a8fa60f85d55c9187d (patch) | |
tree | 714e7abf7ba591d00232d821440e51461175cb9e /cpp/lib/broker/Connection.cpp | |
parent | 750f272ac99e8c830807affb3ae68ab0beeca63f (diff) | |
download | qpid-python-b5c270f10496f522ef6a03a8fa60f85d55c9187d.tar.gz |
* cpp/lib/common/framing/MethodContext.h: Reduced MethodContext to
ChannelAdapter and Method Body. Request ID comes from body,
ChannelAdapter is used to send frames, not OutputHandler.
* cpp/lib/common/framing/ChannelAdapter.h,.cpp: Removed context member.
Context is per-method not per-channel.
* cpp/lib/broker/*: Replace direct use of OutputHandler and ChannelId
with MethodContext (for responses) or ChannelAdapter (for requests.)
Use context request-ID to construct responses, send all bodies via
ChannelAdapter.
* cpp/lib/broker/BrokerAdapter.cpp: Link broker::Channel to BrokerAdapter.
* cpp/lib/broker/*: Remove unnecessary ProtocolVersion parameters.
Fix bogus signatures: ProtocolVersion* -> const ProtocolVersion&
* Cosmetic changes, many files:
- fixed indentation, broke long lines.
- removed unnecessary qpid:: prefixes.
* broker/BrokerAdapter,BrokerChannel: Merged BrokerAdapter into
broker::channel.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@502767 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/broker/Connection.cpp')
-rw-r--r-- | cpp/lib/broker/Connection.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/cpp/lib/broker/Connection.cpp b/cpp/lib/broker/Connection.cpp index b45aa375e6..6694a0ed13 100644 --- a/cpp/lib/broker/Connection.cpp +++ b/cpp/lib/broker/Connection.cpp @@ -60,9 +60,11 @@ Exchange::shared_ptr Connection::findExchange(const string& name){ void Connection::received(qpid::framing::AMQFrame* frame){ - getAdapter(frame->getChannel()).handleBody(frame->getBody()); + getChannel(frame->getChannel()).handleBody(frame->getBody()); } +// TODO aconway 2007-02-02: Should be delegated to the BrokerAdapter +// as it is part of the protocol. void Connection::initiated(qpid::framing::ProtocolInitiation* header) { if (client.get()) // TODO aconway 2007-01-16: correct error code. @@ -72,12 +74,11 @@ void Connection::initiated(qpid::framing::ProtocolInitiation* header) { FieldTable properties; string mechanisms("PLAIN"); string locales("en_US"); - // TODO aconway 2007-01-16: Client call, move to adapter. client->getConnection().start( - MethodContext(0, &getAdapter(0)), + MethodContext(&getChannel(0)), header->getMajor(), header->getMinor(), properties, mechanisms, locales); - getAdapter(0).init(0, *out, client->getProtocolVersion()); + getChannel(0).init(0, *out, client->getProtocolVersion()); } void Connection::idleOut(){} @@ -99,28 +100,19 @@ void Connection::closed(){ void Connection::closeChannel(u_int16_t channel) { getChannel(channel).close(); - adapters.erase(adapters.find(channel)); + channels.erase(channels.find(channel)); } -BrokerAdapter& Connection::getAdapter(u_int16_t id) { - AdapterMap::iterator i = adapters.find(id); - if (i == adapters.end()) { - std::auto_ptr<Channel> ch( - new Channel( - client->getProtocolVersion(), out, id, - framemax, broker.getQueues().getStore(), - settings.stagingThreshold)); - BrokerAdapter* adapter = new BrokerAdapter(ch, *this, broker); - adapters.insert(id, adapter); - return *adapter; - } - else - return *i; -} - -Channel& Connection::getChannel(u_int16_t id) { - return getAdapter(id).getChannel(); +Channel& Connection::getChannel(ChannelId id) { + ChannelMap::iterator i = channels.find(id); + if (i == channels.end()) { + i = channels.insert( + id, new Channel( + *this, id, framemax, broker.getQueues().getStore(), + settings.stagingThreshold)).first; + } + return *i; } |