From 8c7c31362d68be2264b17ae941d5384dec383dbe Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Fri, 5 Apr 2013 08:28:54 -0500 Subject: [PATCH] Adds storage and getter for negotiated subprotocol --- websocketpp/connection.hpp | 16 +++++++++++++++- websocketpp/impl/connection_impl.hpp | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index 1085c04f8d..2e62cd8312 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -519,7 +519,20 @@ public: * @param uri The new URI to set */ void set_uri(uri_ptr uri); - + + ///////////////////////////// + // Subprotocol negotiation // + ///////////////////////////// + + /// Gets the negotated subprotocol + /** + * Retrieves the subprotocol that was negotiated during the handshake. This + * method is valid in the open handler and later. + * + * @return The negotiated subprotocol + */ + const std::string& get_subprotocol() const; + ///////////////////////////////////////////////////////////// // Pass-through access to the request and response objects // ///////////////////////////////////////////////////////////// @@ -952,6 +965,7 @@ private: request_type m_request; response_type m_response; uri_ptr m_uri; + std::string m_subprotocol; const bool m_is_server; alog_type& m_alog; diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index 117740f668..dd0f3cc5e7 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -316,7 +316,10 @@ void connection::set_uri(uri_ptr uri) { - +template +const std::string & connection::get_subprotocol() const { + return m_subprotocol; +}