diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index 39c9b16..3bbbbb3 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -628,7 +628,10 @@ public: */ size_t get_buffered_amount() const; - /// DEPRECATED: use get_buffered_amount instead + /// Get the size of the outgoing write buffer (in payload bytes) + /** + * @deprecated use `get_buffered_amount` instead + */ size_t buffered_amount() const { return get_buffered_amount(); } @@ -1252,26 +1255,6 @@ public: return m_ec; } - //////////////////////////////////////////////////////////////////////// - // The remaining public member functions are for internal/policy use // - // only. Do not call from application code unless you understand what // - // you are doing. // - //////////////////////////////////////////////////////////////////////// - - /// Set Connection Handle - /** - * The connection handle is a token that can be shared outside the - * WebSocket++ core for the purposes of identifying a connection and - * sending it messages. - * - * @param hdl A connection_hdl that the connection will use to refer - * to itself. - */ - void set_handle(connection_hdl hdl) { - m_connection_hdl = hdl; - transport_con_type::set_handle(hdl); - } - /// Get a message buffer /** * Warning: The API related to directly sending message buffers may change @@ -1297,7 +1280,13 @@ public: return m_msg_manager->get_message(op, size); } - void start(); + //////////////////////////////////////////////////////////////////////// + // The remaining public member functions are for internal/policy use // + // only. Do not call from application code unless you understand what // + // you are doing. // + //////////////////////////////////////////////////////////////////////// + + void read_handshake(size_t num_bytes); @@ -1347,6 +1336,27 @@ public: * non-zero otherwise. */ void handle_write_frame(lib::error_code const & ec); +// protected: + // This set of methods would really like to be protected, but doing so + // requires that the endpoint be able to friend the connection. This is + // allowed with C++11, but not prior versions + + /// Start the connection state machine + void start(); + + /// Set Connection Handle + /** + * The connection handle is a token that can be shared outside the + * WebSocket++ core for the purposes of identifying a connection and + * sending it messages. + * + * @param hdl A connection_hdl that the connection will use to refer + * to itself. + */ + void set_handle(connection_hdl hdl) { + m_connection_hdl = hdl; + transport_con_type::set_handle(hdl); + } protected: void handle_transport_init(lib::error_code const & ec); @@ -1358,6 +1368,8 @@ protected: /// set m_response and return an error code indicating status. lib::error_code process_handshake_request(); private: + + /// Completes m_response, serializes it, and sends it out on the wire. void write_http_response(lib::error_code const & ec); diff --git a/websocketpp/endpoint.hpp b/websocketpp/endpoint.hpp index 908a6f9..65584d8 100644 --- a/websocketpp/endpoint.hpp +++ b/websocketpp/endpoint.hpp @@ -85,6 +85,9 @@ public: // TODO: organize these typedef typename connection_type::termination_handler termination_handler; + // This would be ideal. Requires C++11 though + //friend connection; + explicit endpoint(bool p_is_server) : m_alog(config::alog_level, log::channel_type_hint::access) , m_elog(config::elog_level, log::channel_type_hint::error) diff --git a/websocketpp/roles/client_endpoint.hpp b/websocketpp/roles/client_endpoint.hpp index b793873..2de1a10 100644 --- a/websocketpp/roles/client_endpoint.hpp +++ b/websocketpp/roles/client_endpoint.hpp @@ -67,6 +67,8 @@ public: /// Type of the endpoint component of this server typedef endpoint endpoint_type; + friend class connection; + explicit client() : endpoint_type(false) { endpoint_type::m_alog.write(log::alevel::devel, "client constructor"); diff --git a/websocketpp/roles/server_endpoint.hpp b/websocketpp/roles/server_endpoint.hpp index dadcf72..d76eea8 100644 --- a/websocketpp/roles/server_endpoint.hpp +++ b/websocketpp/roles/server_endpoint.hpp @@ -64,6 +64,8 @@ public: /// Type of the endpoint component of this server typedef endpoint endpoint_type; + friend class connection; + explicit server() : endpoint_type(true) { endpoint_type::m_alog.write(log::alevel::devel, "server constructor");