Rename websocket echo servers (fix #46)

This commit is contained in:
Vinnie Falco
2016-08-26 09:11:06 -04:00
parent 3938e5d9ed
commit 605845e4c6
5 changed files with 24 additions and 24 deletions

View File

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

View File

@@ -8,8 +8,8 @@
// Test that header file is self-contained.
#include <beast/websocket/stream.hpp>
#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 <beast/core/streambuf.hpp>
#include <beast/core/to_string.hpp>
@@ -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);

View File

@@ -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<std::thread> 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)};
}

View File

@@ -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 <beast/test/sig_wait.hpp>
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();

View File

@@ -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));
}