diff --git a/test/websocket/CMakeLists.txt b/test/websocket/CMakeLists.txt index b9cc469a..f408b903 100644 --- a/test/websocket/CMakeLists.txt +++ b/test/websocket/CMakeLists.txt @@ -7,8 +7,8 @@ GroupSources(test/websocket "/") add_executable (websocket-tests ${BEAST_INCLUDES} ../../extras/beast/unit_test/main.cpp - websocket_async_echo_peer.hpp - websocket_sync_echo_peer.hpp + websocket_async_echo_server.hpp + websocket_sync_echo_server.hpp error.cpp option.cpp rfc6455.cpp @@ -26,8 +26,8 @@ endif() add_executable (websocket-echo ${BEAST_INCLUDES} - websocket_async_echo_peer.hpp - websocket_sync_echo_peer.hpp + websocket_async_echo_server.hpp + websocket_sync_echo_server.hpp websocket_echo.cpp ) diff --git a/test/websocket/stream.cpp b/test/websocket/stream.cpp index 3b5a07a0..42e3d3d8 100644 --- a/test/websocket/stream.cpp +++ b/test/websocket/stream.cpp @@ -8,8 +8,8 @@ // Test that header file is self-contained. #include -#include "websocket_async_echo_peer.hpp" -#include "websocket_sync_echo_peer.hpp" +#include "websocket_async_echo_server.hpp" +#include "websocket_sync_echo_server.hpp" #include #include @@ -1389,7 +1389,7 @@ public: testBadHandshakes(); testBadResponses(); { - sync_echo_peer server(true, any); + sync_echo_server server(true, any); auto const ep = server.local_endpoint(); //testInvokable1(ep); @@ -1403,7 +1403,7 @@ public: yield_to_mf(ep, &stream_test::testAsyncClient); } { - async_echo_peer server(true, any, 4); + async_echo_server server(true, any, 4); auto const ep = server.local_endpoint(); testSyncClient(ep); testAsyncWriteFrame(ep); diff --git a/test/websocket/websocket_async_echo_peer.hpp b/test/websocket/websocket_async_echo_server.hpp similarity index 97% rename from test/websocket/websocket_async_echo_peer.hpp rename to test/websocket/websocket_async_echo_server.hpp index 35d468b3..35201f00 100644 --- a/test/websocket/websocket_async_echo_peer.hpp +++ b/test/websocket/websocket_async_echo_server.hpp @@ -22,7 +22,7 @@ namespace websocket { // Asynchronous WebSocket echo client/server // -class async_echo_peer +class async_echo_server { public: using endpoint_type = boost::asio::ip::tcp::endpoint; @@ -37,7 +37,7 @@ private: std::vector thread_; public: - async_echo_peer(bool server, + async_echo_server(bool server, endpoint_type const& ep, std::size_t threads) : sock_(ios_) , acceptor_(ios_) @@ -55,7 +55,7 @@ public: boost::asio::socket_base::max_connections, ec); maybe_throw(ec, "listen"); acceptor_.async_accept(sock_, - std::bind(&async_echo_peer::on_accept, this, + std::bind(&async_echo_server::on_accept, this, beast::asio::placeholders::error)); } else @@ -68,7 +68,7 @@ public: [&]{ ios_.run(); }); } - ~async_echo_peer() + ~async_echo_server() { error_code ec; ios_.dispatch( @@ -325,7 +325,7 @@ private: maybe_throw(ec, "accept"); socket_type sock(std::move(sock_)); acceptor_.async_accept(sock_, - std::bind(&async_echo_peer::on_accept, this, + std::bind(&async_echo_server::on_accept, this, beast::asio::placeholders::error)); Peer{false, std::move(sock)}; } diff --git a/test/websocket/websocket_echo.cpp b/test/websocket/websocket_echo.cpp index 98b8c896..636087b4 100644 --- a/test/websocket/websocket_echo.cpp +++ b/test/websocket/websocket_echo.cpp @@ -5,8 +5,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "websocket_async_echo_peer.hpp" -#include "websocket_sync_echo_peer.hpp" +#include "websocket_async_echo_server.hpp" +#include "websocket_sync_echo_server.hpp" #include int main() @@ -14,10 +14,10 @@ int main() using endpoint_type = boost::asio::ip::tcp::endpoint; using address_type = boost::asio::ip::address; - beast::websocket::async_echo_peer s1(true, endpoint_type{ + beast::websocket::async_echo_server s1(true, endpoint_type{ address_type::from_string("127.0.0.1"), 6000 }, 4); - beast::websocket::sync_echo_peer s2(true, endpoint_type{ + beast::websocket::sync_echo_server s2(true, endpoint_type{ address_type::from_string("127.0.0.1"), 6001 }); beast::test::sig_wait(); diff --git a/test/websocket/websocket_sync_echo_peer.hpp b/test/websocket/websocket_sync_echo_server.hpp similarity index 95% rename from test/websocket/websocket_sync_echo_peer.hpp rename to test/websocket/websocket_sync_echo_server.hpp index ba641ef5..a09e4750 100644 --- a/test/websocket/websocket_sync_echo_peer.hpp +++ b/test/websocket/websocket_sync_echo_server.hpp @@ -21,7 +21,7 @@ namespace websocket { // Synchronous WebSocket echo client/server // -class sync_echo_peer +class sync_echo_server { public: using endpoint_type = boost::asio::ip::tcp::endpoint; @@ -36,7 +36,7 @@ private: std::thread thread_; public: - sync_echo_peer(bool server, endpoint_type ep) + sync_echo_server(bool server, endpoint_type ep) : sock_(ios_) , acceptor_(ios_) { @@ -51,12 +51,12 @@ public: boost::asio::socket_base::max_connections, ec); maybe_throw(ec, "listen"); acceptor_.async_accept(sock_, - std::bind(&sync_echo_peer::on_accept, this, + std::bind(&sync_echo_server::on_accept, this, beast::asio::placeholders::error)); thread_ = std::thread{[&]{ ios_.run(); }}; } - ~sync_echo_peer() + ~sync_echo_server() { error_code ec; ios_.dispatch( @@ -100,13 +100,13 @@ private: struct lambda { int id; - sync_echo_peer& self; + sync_echo_server& self; boost::asio::io_service::work work; // Must be destroyed before work otherwise the // io_service could be destroyed before the socket. socket_type sock; - lambda(int id_, sync_echo_peer& self_, + lambda(int id_, sync_echo_server& self_, socket_type&& sock_) : id(id_) , self(self_) @@ -130,7 +130,7 @@ private: static int id_ = 0; std::thread{lambda{++id_, *this, std::move(sock_)}}.detach(); acceptor_.async_accept(sock_, - std::bind(&sync_echo_peer::on_accept, this, + std::bind(&sync_echo_server::on_accept, this, beast::asio::placeholders::error)); }