Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cpp/include/proton/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
#include "./endpoint.hpp"
#include "./session.hpp"
#include "./symbol.hpp"
#include "./value.hpp"

#include <proton/type_compat.h>

#include <map>
#include <string>

/// @file
Expand Down Expand Up @@ -150,6 +152,9 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
/// **Unsettled API** - Extension capabilities desired by the remote peer.
PN_CPP_EXTERN std::vector<symbol> desired_capabilities() const;

/// **Unsettled API** - Connection properties
PN_CPP_EXTERN std::map<symbol, value> properties() const;

/// Get the idle timeout set by the remote peer.
///
/// @see @ref connection_options::idle_timeout
Expand Down
4 changes: 4 additions & 0 deletions cpp/include/proton/connection_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <proton/type_compat.h>

#include <map>
#include <vector>
#include <string>

Expand Down Expand Up @@ -162,6 +163,9 @@ class connection_options {
/// **Unsettled API** - Extension capabilities desired from the remote peer.
PN_CPP_EXTERN connection_options& desired_capabilities(const std::vector<symbol>&);

/// **Unsettled API** - Connection properties.
PN_CPP_EXTERN connection_options& properties(const std::map<symbol, value>&);

/// **Unsettled API** - Set the SASL configuration name.
PN_CPP_EXTERN connection_options& sasl_config_name(const std::string&);

Expand Down
10 changes: 10 additions & 0 deletions cpp/src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "proton_bits.hpp"

#include "proton/codec/map.hpp"
#include "proton/codec/vector.hpp"
#include "proton/connection.hpp"
#include "proton/connection_options.hpp"
Expand Down Expand Up @@ -192,6 +193,15 @@ std::vector<symbol> connection::desired_capabilities() const {
return get_multiple<std::vector<symbol> >(caps);
}

std::map<symbol, value> connection::properties() const {
std::map<symbol, value> props_ret;
value props(pn_connection_remote_properties(pn_object()));
if (!props.empty()) {
get(props, props_ret);
}
return props_ret;
}

bool connection::reconnected() const {
connection_context& cc = connection_context::get(pn_object());
reconnect_context* rc = cc.reconnect_context_.get();
Expand Down
6 changes: 6 additions & 0 deletions cpp/src/connection_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "proton/connection_options.hpp"

#include "proton/connection.hpp"
#include <proton/codec/map.hpp>
#include "proton/codec/vector.hpp"
#include "proton/fwd.hpp"
#include "proton/messaging_handler.hpp"
Expand Down Expand Up @@ -63,6 +64,7 @@ class connection_options::impl {
option<std::string> password;
option<std::vector<symbol> > offered_capabilities;
option<std::vector<symbol> > desired_capabilities;
option<std::map<symbol, value> > properties;
option<reconnect_options_base> reconnect;
option<std::string> reconnect_url;
option<std::vector<std::string> > failover_urls;
Expand Down Expand Up @@ -108,6 +110,8 @@ class connection_options::impl {
value(pn_connection_offered_capabilities(pnc)) = offered_capabilities.value;
if (desired_capabilities.set)
value(pn_connection_desired_capabilities(pnc)) = desired_capabilities.value;
if (properties.set)
value(pn_connection_properties(pnc)) = properties.value;
}

void apply_reconnect_urls(pn_connection_t* pnc) {
Expand Down Expand Up @@ -194,6 +198,7 @@ class connection_options::impl {
password.update(x.password);
offered_capabilities.update(x.offered_capabilities);
desired_capabilities.update(x.desired_capabilities);
properties.update(x.properties);
reconnect.update(x.reconnect);
reconnect_url.update(x.reconnect_url);
failover_urls.update(x.failover_urls);
Expand Down Expand Up @@ -238,6 +243,7 @@ connection_options& connection_options::user(const std::string &user) { impl_->u
connection_options& connection_options::password(const std::string &password) { impl_->password = password; return *this; }
connection_options& connection_options::offered_capabilities(const std::vector<symbol> &caps) { impl_->offered_capabilities = caps; return *this; }
connection_options& connection_options::desired_capabilities(const std::vector<symbol> &caps) { impl_->desired_capabilities = caps; return *this; }
connection_options& connection_options::properties(const std::map<symbol, value> &props) { impl_->properties = props; return *this; }
connection_options& connection_options::reconnect(const reconnect_options &r) {
if (!r.impl_->failover_urls.empty()) {
impl_->failover_urls = r.impl_->failover_urls;
Expand Down
18 changes: 18 additions & 0 deletions cpp/src/container_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class test_handler : public proton::messaging_handler {
std::string peer_container_id;
std::vector<proton::symbol> peer_offered_capabilities;
std::vector<proton::symbol> peer_desired_capabilities;
std::map<proton::symbol, proton::value> peer_properties;
proton::listener listener;
test_listen_handler listen_handler;

Expand All @@ -112,6 +113,7 @@ class test_handler : public proton::messaging_handler {
peer_container_id = c.container_id();
peer_offered_capabilities = c.offered_capabilities();
peer_desired_capabilities = c.desired_capabilities();
peer_properties = c.properties();
c.close();
}
closing = true;
Expand Down Expand Up @@ -179,6 +181,21 @@ int test_container_capabilities() {
ASSERT_EQUAL(th.peer_offered_capabilities[0], proton::symbol("offered"));
ASSERT_EQUAL(th.peer_desired_capabilities.size(), 1u);
ASSERT_EQUAL(th.peer_desired_capabilities[0], proton::symbol("desired"));
ASSERT_EQUAL(th.peer_properties.size(), 0u);
return 0;
}

int test_container_properties() {
proton::connection_options opts;
std::map<proton::symbol, proton::value> props;
props["qpid.client_process"] = "test_process";
props["qpid.client_pid"] = 123;
opts.properties(props);
test_handler th("", opts);
proton::container(th).run();
ASSERT_EQUAL(th.peer_properties.size(), 2u);
ASSERT_EQUAL(th.peer_properties["qpid.client_process"], "test_process");
ASSERT_EQUAL(th.peer_properties["qpid.client_pid"], 123);
return 0;
}

Expand Down Expand Up @@ -475,6 +492,7 @@ int main(int argc, char** argv) {
RUN_ARGV_TEST(failed, test_container_default_container_id());
RUN_ARGV_TEST(failed, test_container_vhost());
RUN_ARGV_TEST(failed, test_container_capabilities());
RUN_ARGV_TEST(failed, test_container_properties());
RUN_ARGV_TEST(failed, test_container_default_vhost());
RUN_ARGV_TEST(failed, test_container_no_vhost());
RUN_ARGV_TEST(failed, test_container_bad_address());
Expand Down