Skip to content

Commit

Permalink
Rename websocket echo servers (fix boostorg#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Aug 26, 2016
1 parent 9fe8160 commit 7afaa04
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions test/websocket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)

Expand Down
8 changes: 4 additions & 4 deletions test/websocket/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -1389,7 +1389,7 @@ class stream_test
testBadHandshakes();
testBadResponses();
{
sync_echo_peer server(true, any);
sync_echo_server server(true, any);
auto const ep = server.local_endpoint();

//testInvokable1(ep);
Expand All @@ -1403,7 +1403,7 @@ class stream_test
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +37,7 @@ class async_echo_peer
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_)
Expand All @@ -55,7 +55,7 @@ class async_echo_peer
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
Expand All @@ -68,7 +68,7 @@ class async_echo_peer
[&]{ ios_.run(); });
}

~async_echo_peer()
~async_echo_server()
{
error_code ec;
ios_.dispatch(
Expand Down Expand Up @@ -325,7 +325,7 @@ class async_echo_peer
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)};
}
Expand Down
8 changes: 4 additions & 4 deletions test/websocket/websocket_echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
// 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()
{
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@ class sync_echo_peer
std::thread thread_;

public:
sync_echo_peer(bool server, endpoint_type ep)
sync_echo_server(bool server, endpoint_type ep)
: sock_(ios_)
, acceptor_(ios_)
{
Expand All @@ -51,12 +51,12 @@ class sync_echo_peer
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(
Expand Down Expand Up @@ -100,13 +100,13 @@ class sync_echo_peer
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_)
Expand All @@ -130,7 +130,7 @@ class sync_echo_peer
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));
}

Expand Down

0 comments on commit 7afaa04

Please sign in to comment.