From c86601f12390b772d67c56f9105453d374278136 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sat, 8 Jun 2013 16:22:19 -0500 Subject: [PATCH] add methods to retrieve WebSocket close codes & reasons --- websocketpp/connection.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index c212d2a77f..adba32f67b 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -775,6 +775,39 @@ public: */ session::state::value get_state() const; + + /// Get the WebSocket close code sent by this endpoint. + /** + * @return The WebSocket close code sent by this endpoint. + */ + close::status::value get_local_close_code() const { + return m_local_close_code; + } + + /// Get the WebSocket close reason sent by this endpoint. + /** + * @return The WebSocket close reason sent by this endpoint. + */ + std::string const & get_local_close_reason() const { + return m_local_close_reason; + } + + /// Get the WebSocket close code sent by the remote endpoint. + /** + * @return The WebSocket close code sent by the remote endpoint. + */ + close::status::value get_remote_close_code() const { + return m_remote_close_code; + } + + /// Get the WebSocket close reason sent by the remote endpoint. + /** + * @return The WebSocket close reason sent by the remote endpoint. + */ + std::string const & get_remote_close_reason() const { + return m_remote_close_reason; + } + /// Get the internal error code for a closed/failed connection /** * Retrieves a machine readable detailed error code indicating the reason