From 1d7cb1bee32496f564c559254d8437471f4269ec Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Thu, 20 Oct 2011 19:51:39 -0500 Subject: [PATCH] updates to connection handler --- src/websocket_connection_handler.hpp | 26 ++++++++++++++++---------- src/websocket_endpoint.hpp | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/websocket_connection_handler.hpp b/src/websocket_connection_handler.hpp index 9c48a46358..f3d93e43bf 100644 --- a/src/websocket_connection_handler.hpp +++ b/src/websocket_connection_handler.hpp @@ -58,16 +58,7 @@ public: // http_error_code - numeric HTTP error code to return to the client // http_error_msg - (optional) string HTTP error code to return to the // client (useful for returning non-standard error codes) - virtual void validate(session_ptr session) = 0; - - // on_fail is called whenever a session is terminated or failed before it - // was successfully established. This happens if there is an error during - // the handshake process or if the server refused the connection. - // - // on_fail will be the last time a session calls its handler. If your - // application will need information from `session` after this function you - // should either save the session_ptr somewhere or copy the data out. - virtual void on_fail(session_ptr session) = 0; + virtual void validate(session_ptr session) {}; // on_open is called after the websocket session has been successfully // established and is in the OPEN state. The session is now avaliable to @@ -99,6 +90,21 @@ public: // this string is valid UTF-8. virtual void on_message(session_ptr session,const std::string &msg) = 0; + + + // #### optional error cases #### + + // on_fail is called whenever a session is terminated or failed before it + // was successfully established. This happens if there is an error during + // the handshake process or if the server refused the connection. + // + // on_fail will be the last time a session calls its handler. If your + // application will need information from `session` after this function you + // should either save the session_ptr somewhere or copy the data out. + virtual void on_fail(session_ptr session) {}; + + // experimental + virtual void on_ping_timeout(session_ptr session) {} }; diff --git a/src/websocket_endpoint.hpp b/src/websocket_endpoint.hpp index 410ec0f000..4f80bf992f 100644 --- a/src/websocket_endpoint.hpp +++ b/src/websocket_endpoint.hpp @@ -42,7 +42,7 @@ namespace websocketpp { namespace websocketpp { -class endpoint { +class endpoint : public boost::enable_shared_from_this { public: virtual bool is_server() = 0; // log