impliments a user overridable endpoint base class and associated tests

This commit is contained in:
Peter Thorson
2013-03-06 08:33:11 -06:00
parent 40abb49483
commit 37b1c65904
4 changed files with 83 additions and 3 deletions

View File

@@ -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<stub_config> s;
BOOST_CHECK( s.extension_value == 5 );
BOOST_CHECK( s.extension_method() == 5 );
}

View File

@@ -51,6 +51,9 @@
// RNG
#include <websocketpp/random/none.hpp>
// User stub base classes
#include <websocketpp/endpoint_base.hpp>
// Extensions
#include <websocketpp/extensions/permessage_compress/disabled.hpp>
@@ -91,7 +94,10 @@ struct core {
/// Transport Endpoint Component
typedef websocketpp::transport::iostream::endpoint<transport_config>
transport_type;
/// User overridable Endpoint base class
typedef websocketpp::endpoint_base endpoint_base;
///
static const size_t connection_read_buffer_size = 512;

View File

@@ -37,10 +37,9 @@ namespace websocketpp {
static const char user_agent[] = "WebSocket++/0.3.0dev";
// creates and manages connections
template <typename connection, typename config>
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.

View File

@@ -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