-// key class for the connection list
-struct connection_id_t {
- const std::string host;
- const int port;
- const std::string vhost;
- // constructed from amqp_connection_info struct
- connection_id_t(const amqp_connection_info& info)
- : host(info.host), port(info.port), vhost(info.vhost) {}
-
- // equality operator and hasher functor are needed
- // so that connection_id_t could be used as key in unordered_map
- bool operator==(const connection_id_t& other) const {
- return host == other.host && port == other.port && vhost == other.vhost;
+// the amqp_connection_info struct does not hold any memory and just points to the URL string
+// so, strings are copied into connection_id_t
+connection_id_t::connection_id_t(const amqp_connection_info& info, const std::string& _exchange)
+ : host(info.host), port(info.port), vhost(info.vhost), exchange(_exchange), ssl(info.ssl) {}
+
+// equality operator and hasher functor are needed
+// so that connection_id_t could be used as key in unordered_map
+bool operator==(const connection_id_t& lhs, const connection_id_t& rhs) {
+ return lhs.host == rhs.host && lhs.port == rhs.port &&
+ lhs.vhost == rhs.vhost && lhs.exchange == rhs.exchange;
+}
+
+struct connection_id_hasher {
+ std::size_t operator()(const connection_id_t& k) const {
+ std::size_t h = 0;
+ boost::hash_combine(h, k.host);
+ boost::hash_combine(h, k.port);
+ boost::hash_combine(h, k.vhost);
+ boost::hash_combine(h, k.exchange);
+ return h;