diff options
author | Alan Conway <aconway@apache.org> | 2007-01-29 16:13:24 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-01-29 16:13:24 +0000 |
commit | 5a1b8a846bdfa5cb517da0c507f3dc3a8ceec25d (patch) | |
tree | f9a982b65400154a86edd02faf75da143a96404c /cpp/lib/client/ResponseHandler.cpp | |
parent | 5d28464c46c1e64ded078a4585f0f49e30b8b5d6 (diff) | |
download | qpid-python-5a1b8a846bdfa5cb517da0c507f3dc3a8ceec25d.tar.gz |
* Added ClientAdapter - client side ChannelAdapter. Updated client side.
* Moved ChannelAdapter initialization from ctor to init(), updated broker side.
* Improved various exception messages with boost::format messages.
* Removed unnecssary virtual inheritance.
* Widespread: fixed incorrect non-const ProtocolVersion& parameters.
* Client API: pass channels by reference, not pointer.
* codegen:
- MethodBodyClass.h.templ: Added CLASS_ID, METHOD_ID and isA() template.
- Various: fixed non-const ProtocolVersion& parameters.
* cpp/bootstrap: Allow config arguments with -build.
* cpp/gen/Makefile.am: Merged codegen fixes from trunk.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@501087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/client/ResponseHandler.cpp')
-rw-r--r-- | cpp/lib/client/ResponseHandler.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/cpp/lib/client/ResponseHandler.cpp b/cpp/lib/client/ResponseHandler.cpp index 68c7e52013..8950138f5e 100644 --- a/cpp/lib/client/ResponseHandler.cpp +++ b/cpp/lib/client/ResponseHandler.cpp @@ -18,27 +18,35 @@ * under the License. * */ +#include <boost/format.hpp> + #include <ResponseHandler.h> #include <sys/Monitor.h> #include <QpidError.h> +#include "amqp_types.h" using namespace qpid::sys; +using namespace qpid::framing; + +namespace qpid { +namespace client { -qpid::client::ResponseHandler::ResponseHandler() : waiting(false){} +ResponseHandler::ResponseHandler() : waiting(false){} -qpid::client::ResponseHandler::~ResponseHandler(){} +ResponseHandler::~ResponseHandler(){} -bool qpid::client::ResponseHandler::validate(const qpid::framing::AMQMethodBody& expected){ - return response != 0 && expected.match(response.get()); +bool ResponseHandler::validate(ClassId c, MethodId m) { + return response != 0 && + response->amqpClassId() ==c && response->amqpMethodId() == m; } -void qpid::client::ResponseHandler::waitForResponse(){ +void ResponseHandler::waitForResponse(){ Monitor::ScopedLock l(monitor); while (waiting) monitor.wait(); } -void qpid::client::ResponseHandler::signalResponse( +void ResponseHandler::signalResponse( qpid::framing::AMQMethodBody::shared_ptr _response) { Monitor::ScopedLock l(monitor); @@ -47,15 +55,26 @@ void qpid::client::ResponseHandler::signalResponse( monitor.notify(); } -void qpid::client::ResponseHandler::receive(const qpid::framing::AMQMethodBody& expected){ +void ResponseHandler::receive(ClassId c, MethodId m) { Monitor::ScopedLock l(monitor); while (waiting) monitor.wait(); - if(!validate(expected)){ - THROW_QPID_ERROR(PROTOCOL_ERROR, "Protocol Error"); + if (!response) { + THROW_QPID_ERROR( + PROTOCOL_ERROR, "Channel closed unexpectedly."); + } + if(!validate(response->amqpClassId(), response->amqpMethodId())) { + THROW_QPID_ERROR( + PROTOCOL_ERROR, + (boost::format( + "Expected class:method %d:%d, got %d:%d") + % c % m % response->amqpClassId() % response->amqpMethodId() + ).str()); } } -void qpid::client::ResponseHandler::expect(){ +void ResponseHandler::expect(){ waiting = true; } + +}} // namespace qpid::client |