I have a piece of code that uses websocketpp to run a server. I would like to identify the different connections that come to the server. To do so it seems that the websocketpp::connection_hdl hdl
should be used.
namespace websocketpp {
/// A handle to uniquely identify a connection.
/**
* This type uniquely identifies a connection. It is implemented as a weak
* pointer to the connection in question. This provides uniqueness across
* multiple endpoints and ensures that IDs never conflict or run out.
*
* It is safe to make copies of this handle, store those copies in containers,
* and use them from other threads.
*
* This handle can be upgraded to a full shared_ptr using
* `endpoint::get_con_from_hdl()` from within a handler fired by the connection
* that owns the handler.
*/
typedef lib::weak_ptr<void> connection_hdl;
But as you can see it is a weak_ptr<void>
that I don't know how it can be compared with others.
I have a map with websocketpp::connection_hdl
as index that when I try to see if has an existent index with:
std::map<websocketpp::connection_hdl, asio::ip::tcp::socket> active_connections;
if (active_connections.count(con->get_socket()) > 0) {}
The compiler complains with:
error C2678: binary '<': no operator found which takes a left-hand operand of type 'const _Ty' (or there is no acceptable conversion)
Is there any way I can get the socket from the connection (the raw integer socket). If I can I could use that as an index and solve the problem.
Can you see any other way to fix it?