From 468b4b6ddaa3d96bb743cdbd27ded651eea31847 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 11 Sep 2008 04:45:26 +0000 Subject: Refactored c++ client library to allow multiple protocols to be used simultaneously: - Added in capability for client library plugins: Client library will load in plugin modules from the client library module directory on library load. - Add protocol option into the standard client command line options - Split plugin module load area into daemon and client; default daemon module directory is now /qpid/daemon, default client module directory is /qpid/client. - Changed names of plugins to leave out libqpid prefix git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@694113 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/ConnectionImpl.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp') diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index f623530f98..f180c4f23e 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -40,7 +40,6 @@ using namespace qpid::framing::connection;//for connection error codes ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSettings& settings) : Bounds(settings.maxFrameSize * settings.bounds), handler(settings, v), - connector(new Connector(v, settings, this)), version(v) { QPID_LOG(debug, "ConnectionImpl created for " << version); @@ -48,8 +47,6 @@ ConnectionImpl::ConnectionImpl(framing::ProtocolVersion v, const ConnectionSetti handler.out = boost::bind(&Connector::send, boost::ref(connector), _1); handler.onClose = boost::bind(&ConnectionImpl::closed, this, CLOSE_CODE_NORMAL, std::string()); - connector->setInputHandler(&handler); - connector->setShutdownHandler(this); //only set error handler once open handler.onError = boost::bind(&ConnectionImpl::closed, this, _1, _2); @@ -59,7 +56,7 @@ ConnectionImpl::~ConnectionImpl() { // Important to close the connector first, to ensure the // connector thread does not call on us while the destructor // is running. - connector->close(); + if (connector) connector->close(); } void ConnectionImpl::addSession(const boost::shared_ptr& session) @@ -93,9 +90,16 @@ bool ConnectionImpl::isOpen() const } -void ConnectionImpl::open(const std::string& host, int port) +void ConnectionImpl::open() { - QPID_LOG(info, "Connecting to " << host << ":" << port); + const std::string& protocol = handler.protocol; + const std::string& host = handler.host; + int port = handler.port; + QPID_LOG(info, "Connecting to " << protocol << ":" << host << ":" << port); + + connector.reset(Connector::create(protocol, version, handler, this)); + connector->setInputHandler(&handler); + connector->setShutdownHandler(this); connector->connect(host, port); connector->init(); handler.waitForOpen(); -- cgit v1.2.1