diff --git a/test/endpoint/endpoint.cpp b/test/endpoint/endpoint.cpp index 1a435abb8d..ad9a96f1fc 100644 --- a/test/endpoint/endpoint.cpp +++ b/test/endpoint/endpoint.cpp @@ -56,3 +56,40 @@ BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) { boost::asio::io_service ios; s.init_asio(&ios); } + +struct endpoint_extension { + endpoint_extension() : extension_value(5) {} + + int extension_method() { + return extension_value; + } + + int extension_value; +}; + +struct stub_config : public websocketpp::config::core { + typedef core::concurrency_type concurrency_type; + + typedef core::request_type request_type; + typedef core::response_type response_type; + + typedef core::message_type message_type; + typedef core::con_msg_manager_type con_msg_manager_type; + typedef core::endpoint_msg_manager_type endpoint_msg_manager_type; + + typedef core::alog_type alog_type; + typedef core::elog_type elog_type; + + typedef core::rng_type rng_type; + + typedef core::transport_type transport_type; + + typedef endpoint_extension endpoint_base; +}; + +BOOST_AUTO_TEST_CASE( endpoint_extensions ) { + websocketpp::server s; + + BOOST_CHECK( s.extension_value == 5 ); + BOOST_CHECK( s.extension_method() == 5 ); +} diff --git a/websocketpp/config/core.hpp b/websocketpp/config/core.hpp index d8c730ee55..8236403532 100644 --- a/websocketpp/config/core.hpp +++ b/websocketpp/config/core.hpp @@ -51,6 +51,9 @@ // RNG #include +// User stub base classes +#include + // Extensions #include @@ -91,7 +94,10 @@ struct core { /// Transport Endpoint Component typedef websocketpp::transport::iostream::endpoint transport_type; - + + /// User overridable Endpoint base class + typedef websocketpp::endpoint_base endpoint_base; + /// static const size_t connection_read_buffer_size = 512; diff --git a/websocketpp/endpoint.hpp b/websocketpp/endpoint.hpp index fc617939c1..c5af1e0d5b 100644 --- a/websocketpp/endpoint.hpp +++ b/websocketpp/endpoint.hpp @@ -37,10 +37,9 @@ namespace websocketpp { static const char user_agent[] = "WebSocket++/0.3.0dev"; - // creates and manages connections template -class endpoint : public config::transport_type { +class endpoint : public config::transport_type, public config::endpoint_base { public: // Import appropriate types from our helper class // See endpoint_types for more details. diff --git a/websocketpp/endpoint_base.hpp b/websocketpp/endpoint_base.hpp new file mode 100644 index 0000000000..3327112568 --- /dev/null +++ b/websocketpp/endpoint_base.hpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, Peter Thorson. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the WebSocket++ Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef WEBSOCKETPP_ENDPOINT_BASE_HPP +#define WEBSOCKETPP_ENDPOINT_BASE_HPP + +namespace websocketpp { + +/// Stub for user supplied base class. +class endpoint_base {}; + +} // namespace websocketpp + +#endif // WEBSOCKETPP_ENDPOINT_BASE_HPP