Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
endpoint.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Peter Thorson. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the WebSocket++ Project nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27//#define BOOST_TEST_DYN_LINK
28#define BOOST_TEST_MODULE endpoint
29#include <boost/test/unit_test.hpp>
30
31#include <iostream>
32#include <sstream>
33
36
40
44
48
49BOOST_AUTO_TEST_CASE( initialize_server_asio ) {
51 s.init_asio();
52}
53
54BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) {
56 boost::asio::io_service ios;
57 s.init_asio(&ios);
58}
59
60#ifdef _WEBSOCKETPP_MOVE_SEMANTICS_
61BOOST_AUTO_TEST_CASE( move_construct_server_core ) {
63
65}
66
67/*
68// temporary disable because library doesn't pass
69BOOST_AUTO_TEST_CASE( emplace ) {
70 std::stringstream out1;
71 std::stringstream out2;
72
73 std::vector<websocketpp::server<websocketpp::config::asio_tls>> v;
74
75 v.emplace_back();
76 v.emplace_back();
77
78 v[0].get_alog().set_ostream(&out1);
79 v[0].get_alog().set_ostream(&out2);
80
81 v[0].get_alog().write(websocketpp::log::alevel::app,"devel0");
82 v[1].get_alog().write(websocketpp::log::alevel::app,"devel1");
83 BOOST_CHECK( out1.str().size() > 0 );
84 BOOST_CHECK( out2.str().size() > 0 );
85}*/
86
87#endif // _WEBSOCKETPP_MOVE_SEMANTICS_
88
91
93 return extension_value;
94 }
95
96 bool is_server() const {
97 return false;
98 }
99
101};
102
104 typedef core::concurrency_type concurrency_type;
105
106 typedef core::request_type request_type;
107 typedef core::response_type response_type;
108
109 typedef core::message_type message_type;
110 typedef core::con_msg_manager_type con_msg_manager_type;
111 typedef core::endpoint_msg_manager_type endpoint_msg_manager_type;
112
113 typedef core::alog_type alog_type;
114 typedef core::elog_type elog_type;
115
116 typedef core::rng_type rng_type;
117
118 typedef core::transport_type transport_type;
119
121};
122
123BOOST_AUTO_TEST_CASE( endpoint_extensions ) {
125
126 BOOST_CHECK_EQUAL( s.extension_value, 5 );
127 BOOST_CHECK_EQUAL( s.extension_method(), 5 );
128
129 BOOST_CHECK( s.is_server() );
130}
131
132BOOST_AUTO_TEST_CASE( listen_after_listen_failure ) {
135
138
139 websocketpp::lib::error_code ec;
140
141 server1.init_asio();
142 server2.init_asio();
143
144 boost::asio::ip::tcp::endpoint ep1(boost::asio::ip::address::from_string("127.0.0.1"), 12345);
145 boost::asio::ip::tcp::endpoint ep2(boost::asio::ip::address::from_string("127.0.0.1"), 23456);
146
147 server1.listen(ep1, ec);
148 BOOST_CHECK(!ec);
149
150 server2.listen(ep1, ec);
151 BOOST_REQUIRE_EQUAL(ec, make_error_code(pass_through));
152
153 server2.listen(ep2, ec);
154 BOOST_CHECK(!ec);
155}
Server endpoint role based on the given config.
BOOST_AUTO_TEST_CASE(construct_server_iostream)
Definition endpoint.cpp:37
lib::error_code make_error_code(error::value e)
Create an error code with the given value and the asio transport category.
Definition base.hpp:217
@ pass_through
there was an error in the underlying transport library
Definition base.hpp:171
bool is_server() const
Definition endpoint.cpp:96
core::alog_type alog_type
core::endpoint_msg_manager_type endpoint_msg_manager_type
core::elog_type elog_type
core::message_type message_type
core::rng_type rng_type
endpoint_extension endpoint_base
Definition endpoint.cpp:120
core::transport_type transport_type
core::con_msg_manager_type con_msg_manager_type
core::request_type request_type
core::concurrency_type concurrency_type
core::response_type response_type
Server config with iostream transport.
Definition core.hpp:67
char * s