Commit b2d9a553 authored by Dominik Charousset's avatar Dominik Charousset

Get rid of namespace caf::net::binary

The idea of a generic binary layer for message-oriented processing seems
not really applicable. Hence, we merge all classes from `net::binary` to
`net::lp`. This was the only place where we have used those classes, so
it makes more sense to have them merged in one place.
parent fda97739
...@@ -60,7 +60,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -60,7 +60,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
.accept(port) .accept(port)
// Limit how many clients may be connected at any given time. // Limit how many clients may be connected at any given time.
.max_connections(max_connections) .max_connections(max_connections)
// When started, run our worker actor to handle incoming connections. // When started, run our worker actor to handle incoming requests.
.start([&sys](auto requests) { .start([&sys](auto requests) {
// Note: requests is an async::consumer_resource<http::request>. // Note: requests is an async::consumer_resource<http::request>.
sys.spawn([requests](caf::event_based_actor* self) { sys.spawn([requests](caf::event_based_actor* self) {
......
...@@ -16,18 +16,8 @@ ...@@ -16,18 +16,8 @@
using namespace std::literals; using namespace std::literals;
// -- convenience type aliases ------------------------------------------------- namespace lp = caf::net::lp;
namespace ssl = caf::net::ssl;
// The trait for translating between bytes on the wire and flow items. The
// binary default trait operates on binary::frame items.
using trait = caf::net::binary::default_trait;
// An implicitly shared type for storing a binary frame.
using bin_frame = caf::net::binary::frame;
// Each client gets a UUID for identifying it. While processing messages, we add
// this ID to the input to tag it.
using message_t = std::pair<caf::uuid, bin_frame>;
// -- constants ---------------------------------------------------------------- // -- constants ----------------------------------------------------------------
...@@ -52,7 +42,6 @@ struct config : caf::actor_system_config { ...@@ -52,7 +42,6 @@ struct config : caf::actor_system_config {
// -- main --------------------------------------------------------------------- // -- main ---------------------------------------------------------------------
int caf_main(caf::actor_system& sys, const config& cfg) { int caf_main(caf::actor_system& sys, const config& cfg) {
namespace ssl = caf::net::ssl;
// Read the configuration. // Read the configuration.
auto use_ssl = caf::get_or(cfg, "tls.enable", false); auto use_ssl = caf::get_or(cfg, "tls.enable", false);
auto port = caf::get_or(cfg, "port", default_port); auto port = caf::get_or(cfg, "port", default_port);
...@@ -88,7 +77,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -88,7 +77,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
<< "*** use CTRL+D or CTRL+C to terminate\n"; << "*** use CTRL+D or CTRL+C to terminate\n";
self->quit(); self->quit();
}) })
.for_each([](const bin_frame& frame) { .for_each([](const lp::frame& frame) {
// Interpret the bytes as ASCII characters. // Interpret the bytes as ASCII characters.
auto bytes = frame.bytes(); auto bytes = frame.bytes();
auto str = std::string_view{ auto str = std::string_view{
...@@ -103,7 +92,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -103,7 +92,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
}); });
// Spin up a second worker that reads from std::cin and sends each // Spin up a second worker that reads from std::cin and sends each
// line to the server. Put that to its own thread since it's doing // line to the server. Put that to its own thread since it's doing
// I/O. // blocking I/O calls.
sys.spawn<caf::detached>([push, name] { sys.spawn<caf::detached>([push, name] {
auto lines = caf::async::make_blocking_producer(push); auto lines = caf::async::make_blocking_producer(push);
if (!lines) if (!lines)
...@@ -112,7 +101,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -112,7 +101,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
auto prefix = name + ": "; auto prefix = name + ": ";
while (std::getline(std::cin, line)) { while (std::getline(std::cin, line)) {
line.insert(line.begin(), prefix.begin(), prefix.end()); line.insert(line.begin(), prefix.begin(), prefix.end());
lines->push(bin_frame{caf::as_bytes(caf::make_span(line))}); lines->push(lp::frame{caf::as_bytes(caf::make_span(line))});
line.clear(); line.clear();
} }
}); });
......
...@@ -12,18 +12,7 @@ ...@@ -12,18 +12,7 @@
#include <iostream> #include <iostream>
#include <utility> #include <utility>
// -- convenience type aliases ------------------------------------------------- namespace lp = caf::net::lp;
// The trait for translating between bytes on the wire and flow items. The
// binary default trait operates on binary::frame items.
using trait = caf::net::binary::default_trait;
// An implicitly shared type for storing a binary frame.
using bin_frame = caf::net::binary::frame;
// Each client gets a UUID for identifying it. While processing messages, we add
// this ID to the input to tag it.
using message_t = std::pair<caf::uuid, bin_frame>;
// -- constants ---------------------------------------------------------------- // -- constants ----------------------------------------------------------------
...@@ -47,11 +36,14 @@ struct config : caf::actor_system_config { ...@@ -47,11 +36,14 @@ struct config : caf::actor_system_config {
// -- multiplexing logic ------------------------------------------------------- // -- multiplexing logic -------------------------------------------------------
void worker_impl(caf::event_based_actor* self, void worker_impl(caf::event_based_actor* self,
trait::acceptor_resource events) { lp::default_trait::acceptor_resource events) {
// Each client gets a UUID for identifying it. While processing messages, we
// add this ID to the input to tag it.
using message_t = std::pair<caf::uuid, lp::frame>;
// Allows us to push new flows into the central merge point. // Allows us to push new flows into the central merge point.
caf::flow::item_publisher<caf::flow::observable<message_t>> msg_pub{self}; caf::flow::item_publisher<caf::flow::observable<message_t>> pub{self};
// Our central merge point combines all inputs into a single, shared flow. // Our central merge point combines all inputs into a single, shared flow.
auto messages = msg_pub.as_observable().merge().share(); auto messages = pub.as_observable().merge().share();
// Have one subscription for debug output. This also makes sure that the // Have one subscription for debug output. This also makes sure that the
// shared observable stays subscribed to the merger. // shared observable stays subscribed to the merger.
messages.for_each([](const message_t& msg) { messages.for_each([](const message_t& msg) {
...@@ -63,8 +55,7 @@ void worker_impl(caf::event_based_actor* self, ...@@ -63,8 +55,7 @@ void worker_impl(caf::event_based_actor* self,
events events
.observe_on(self) // .observe_on(self) //
.for_each( .for_each(
[self, messages, pub = std::move(msg_pub)] // [self, messages, pub = std::move(pub)](const auto& event) mutable {
(const trait::accept_event& event) mutable {
// Each connection gets a unique ID. // Each connection gets a unique ID.
auto conn = caf::uuid::random(); auto conn = caf::uuid::random();
std::cout << "*** accepted new connection " << to_string(conn) << '\n'; std::cout << "*** accepted new connection " << to_string(conn) << '\n';
...@@ -90,7 +81,7 @@ void worker_impl(caf::event_based_actor* self, ...@@ -90,7 +81,7 @@ void worker_impl(caf::event_based_actor* self,
.do_on_complete([conn] { .do_on_complete([conn] {
std::cout << "*** lost connection " << to_string(conn) << '\n'; std::cout << "*** lost connection " << to_string(conn) << '\n';
}) })
.map([conn](const bin_frame& frame) { .map([conn](const lp::frame& frame) {
return message_t{conn, frame}; return message_t{conn, frame};
}) })
.as_observable(); .as_observable();
...@@ -126,7 +117,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -126,7 +117,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
// Limit how many clients may be connected at any given time. // Limit how many clients may be connected at any given time.
.max_connections(max_connections) .max_connections(max_connections)
// When started, run our worker actor to handle incoming connections. // When started, run our worker actor to handle incoming connections.
.start([&sys](trait::acceptor_resource accept_events) { .start([&sys](lp::default_trait::acceptor_resource accept_events) {
sys.spawn(worker_impl, std::move(accept_events)); sys.spawn(worker_impl, std::move(accept_events));
}); });
// Report any error to the user. // Report any error to the user.
......
...@@ -16,6 +16,8 @@ CAF_POP_WARNINGS ...@@ -16,6 +16,8 @@ CAF_POP_WARNINGS
using namespace std; using namespace std;
using namespace caf; using namespace caf;
namespace lp = caf::net::lp;
ChatWidget::ChatWidget(QWidget* parent) ChatWidget::ChatWidget(QWidget* parent)
: super(parent), input_(nullptr), output_(nullptr) { : super(parent), input_(nullptr), output_(nullptr) {
// nop // nop
...@@ -26,8 +28,8 @@ ChatWidget::~ChatWidget() { ...@@ -26,8 +28,8 @@ ChatWidget::~ChatWidget() {
} }
void ChatWidget::init(actor_system& system, const std::string& name, void ChatWidget::init(actor_system& system, const std::string& name,
caf::async::consumer_resource<bin_frame> pull, caf::async::consumer_resource<lp::frame> pull,
caf::async::producer_resource<bin_frame> push) { caf::async::producer_resource<lp::frame> push) {
name_ = QString::fromUtf8(name); name_ = QString::fromUtf8(name);
print("*** hello " + name_); print("*** hello " + name_);
super::init(system); super::init(system);
...@@ -37,7 +39,7 @@ void ChatWidget::init(actor_system& system, const std::string& name, ...@@ -37,7 +39,7 @@ void ChatWidget::init(actor_system& system, const std::string& name,
.do_finally([this] { // .do_finally([this] { //
print("*** chatroom offline: lost connection to the server"); print("*** chatroom offline: lost connection to the server");
}) })
.for_each([this](const bin_frame& frame) { .for_each([this](const lp::frame& frame) {
auto bytes = frame.bytes(); auto bytes = frame.bytes();
auto str = std::string_view{reinterpret_cast<const char*>(bytes.data()), auto str = std::string_view{reinterpret_cast<const char*>(bytes.data()),
bytes.size()}; bytes.size()};
...@@ -56,7 +58,7 @@ void ChatWidget::init(actor_system& system, const std::string& name, ...@@ -56,7 +58,7 @@ void ChatWidget::init(actor_system& system, const std::string& name,
auto encoded = str.toUtf8(); auto encoded = str.toUtf8();
auto bytes = caf::as_bytes( auto bytes = caf::as_bytes(
caf::make_span(encoded.data(), static_cast<size_t>(encoded.size()))); caf::make_span(encoded.data(), static_cast<size_t>(encoded.size())));
return bin_frame{bytes}; return lp::frame{bytes};
}) })
.subscribe(push); .subscribe(push);
set_message_handler([=](actor_companion*) -> message_handler { set_message_handler([=](actor_companion*) -> message_handler {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/async/spsc_buffer.hpp" #include "caf/async/spsc_buffer.hpp"
#include "caf/mixin/actor_widget.hpp" #include "caf/mixin/actor_widget.hpp"
#include "caf/net/binary/frame.hpp" #include "caf/net/lp/frame.hpp"
CAF_PUSH_WARNINGS CAF_PUSH_WARNINGS
#include <QLineEdit> #include <QLineEdit>
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
using super = caf::mixin::actor_widget<QWidget>; using super = caf::mixin::actor_widget<QWidget>;
using bin_frame = caf::net::binary::frame; using frame = caf::net::lp::frame;
using publisher_type = caf::flow::item_publisher<QString>; using publisher_type = caf::flow::item_publisher<QString>;
...@@ -39,8 +39,8 @@ public: ...@@ -39,8 +39,8 @@ public:
~ChatWidget(); ~ChatWidget();
void init(caf::actor_system& system, const std::string& name, void init(caf::actor_system& system, const std::string& name,
caf::async::consumer_resource<bin_frame> pull, caf::async::consumer_resource<frame> pull,
caf::async::producer_resource<bin_frame> push); caf::async::producer_resource<frame> push);
public slots: public slots:
......
...@@ -84,11 +84,11 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -84,11 +84,11 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
}) })
// When started, run our worker actor to handle incoming connections. // When started, run our worker actor to handle incoming connections.
.start([&sys](trait::acceptor_resource<> events) { .start([&sys](trait::acceptor_resource<> events) {
using event_t = trait::accept_event<>;
sys.spawn([events](caf::event_based_actor* self) { sys.spawn([events](caf::event_based_actor* self) {
// For each buffer pair, we create a new flow ... // For each buffer pair, we create a new flow ...
self->make_observable().from_resource(events).for_each( self->make_observable()
[self](const event_t& ev) { .from_resource(events) //
.for_each([self](const trait::accept_event<>& ev) {
// ... that simply pushes data back to the sender. // ... that simply pushes data back to the sender.
auto [pull, push] = ev.data(); auto [pull, push] = ev.data();
pull.observe_on(self) pull.observe_on(self)
......
...@@ -184,7 +184,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) { ...@@ -184,7 +184,7 @@ int caf_main(caf::actor_system& sys, const config& cfg) {
.accept(port) .accept(port)
// Limit how many clients may be connected at any given time. // Limit how many clients may be connected at any given time.
.max_connections(max_connections) .max_connections(max_connections)
// Accept only requests for path "/". // Add handler for incoming connections.
.on_request([](ws::acceptor<>& acc, const http::header&) { .on_request([](ws::acceptor<>& acc, const http::header&) {
// Ignore all header fields and accept the connection. // Ignore all header fields and accept the connection.
acc.accept(); acc.accept();
......
...@@ -33,10 +33,6 @@ caf_add_component( ...@@ -33,10 +33,6 @@ caf_add_component(
src/detail/rfc6455.cpp src/detail/rfc6455.cpp
src/net/abstract_actor_shell.cpp src/net/abstract_actor_shell.cpp
src/net/actor_shell.cpp src/net/actor_shell.cpp
src/net/binary/default_trait.cpp
src/net/binary/frame.cpp
src/net/binary/lower_layer.cpp
src/net/binary/upper_layer.cpp
src/net/datagram_socket.cpp src/net/datagram_socket.cpp
src/net/dsl/config_base.cpp src/net/dsl/config_base.cpp
src/net/generic_lower_layer.cpp src/net/generic_lower_layer.cpp
...@@ -52,7 +48,11 @@ caf_add_component( ...@@ -52,7 +48,11 @@ caf_add_component(
src/net/http/upper_layer.cpp src/net/http/upper_layer.cpp
src/net/http/v1.cpp src/net/http/v1.cpp
src/net/ip.cpp src/net/ip.cpp
src/net/lp/default_trait.cpp
src/net/lp/frame.cpp
src/net/lp/framing.cpp src/net/lp/framing.cpp
src/net/lp/lower_layer.cpp
src/net/lp/upper_layer.cpp
src/net/middleman.cpp src/net/middleman.cpp
src/net/multiplexer.cpp src/net/multiplexer.cpp
src/net/network_socket.cpp src/net/network_socket.cpp
...@@ -97,11 +97,11 @@ caf_add_component( ...@@ -97,11 +97,11 @@ caf_add_component(
detail.rfc6455 detail.rfc6455
net.accept_socket net.accept_socket
net.actor_shell net.actor_shell
net.binary.frame
net.datagram_socket net.datagram_socket
net.http.server net.http.server
net.ip net.ip
net.length_prefix_framing net.length_prefix_framing
net.lp.frame
net.multiplexer net.multiplexer
net.network_socket net.network_socket
net.octet_stream.transport net.octet_stream.transport
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "caf/async/spsc_buffer.hpp" #include "caf/async/spsc_buffer.hpp"
#include "caf/detail/flow_bridge_base.hpp" #include "caf/detail/flow_bridge_base.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/binary/lower_layer.hpp" #include "caf/net/lp/lower_layer.hpp"
#include "caf/net/binary/upper_layer.hpp" #include "caf/net/lp/upper_layer.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include <utility> #include <utility>
...@@ -19,15 +19,14 @@ namespace caf::detail { ...@@ -19,15 +19,14 @@ namespace caf::detail {
/// Convenience alias for referring to the base type of @ref flow_bridge. /// Convenience alias for referring to the base type of @ref flow_bridge.
template <class Trait> template <class Trait>
using binary_flow_bridge_base_t using lp_flow_bridge_base
= detail::flow_bridge_base<net::binary::upper_layer, net::binary::lower_layer, = flow_bridge_base<net::lp::upper_layer, net::lp::lower_layer, Trait>;
Trait>;
/// Translates between a message-oriented transport and data flows. /// Translates between a message-oriented transport and data flows.
template <class Trait> template <class Trait>
class binary_flow_bridge : public binary_flow_bridge_base_t<Trait> { class lp_flow_bridge : public lp_flow_bridge_base<Trait> {
public: public:
using super = binary_flow_bridge_base_t<Trait>; using super = lp_flow_bridge_base<Trait>;
using input_type = typename Trait::input_type; using input_type = typename Trait::input_type;
...@@ -41,7 +40,7 @@ public: ...@@ -41,7 +40,7 @@ public:
return super::trait_.convert(item, bytes) && super::down_->end_message(); return super::trait_.convert(item, bytes) && super::down_->end_message();
} }
// -- implementation of binary::lower_layer ---------------------------------- // -- implementation of lp::lower_layer --------------------------------------
ptrdiff_t consume(byte_span buf) override { ptrdiff_t consume(byte_span buf) override {
if (!super::out_) if (!super::out_)
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "caf/actor_system.hpp" #include "caf/actor_system.hpp"
#include "caf/async/consumer_adapter.hpp" #include "caf/async/consumer_adapter.hpp"
#include "caf/async/producer_adapter.hpp" #include "caf/async/producer_adapter.hpp"
#include "caf/net/binary/lower_layer.hpp" #include "caf/net/lp/lower_layer.hpp"
#include "caf/net/binary/upper_layer.hpp" #include "caf/net/lp/upper_layer.hpp"
#include "caf/net/multiplexer.hpp" #include "caf/net/multiplexer.hpp"
#include "caf/net/socket_manager.hpp" #include "caf/net/socket_manager.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
...@@ -32,7 +32,7 @@ namespace caf::net { ...@@ -32,7 +32,7 @@ namespace caf::net {
/// }; /// };
/// ~~~ /// ~~~
template <class Trait> template <class Trait>
class message_flow_bridge : public binary::upper_layer { class message_flow_bridge : public lp::upper_layer {
public: public:
/// The input type for the application. /// The input type for the application.
using input_type = typename Trait::input_type; using input_type = typename Trait::input_type;
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
// nop // nop
} }
error start(net::socket_manager* mgr, binary::lower_layer* down) { error start(net::socket_manager* mgr, lp::lower_layer* down) {
down_ = down; down_ = down;
if (auto in = make_consumer_adapter(in_res_, mgr->mpx_ptr(), if (auto in = make_consumer_adapter(in_res_, mgr->mpx_ptr(),
do_wakeup_cb())) { do_wakeup_cb())) {
...@@ -158,7 +158,7 @@ private: ...@@ -158,7 +158,7 @@ private:
} }
/// Points to the next layer down the protocol stack. /// Points to the next layer down the protocol stack.
binary::lower_layer* down_ = nullptr; lp::lower_layer* down_ = nullptr;
/// Incoming messages, serialized to the socket. /// Incoming messages, serialized to the socket.
async::consumer_adapter<input_type> in_; async::consumer_adapter<input_type> in_;
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
namespace caf::net::binary {
class frame;
class lower_layer;
class upper_layer;
} // namespace caf::net::binary
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
#pragma once #pragma once
#include "caf/fwd.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/ssl/fwd.hpp"
namespace caf::net::dsl { namespace caf::net::dsl {
/// Base type for our DSL classes to configure a factory object. /// Base type for our DSL classes to configure a factory object.
......
...@@ -95,3 +95,60 @@ namespace caf::detail { ...@@ -95,3 +95,60 @@ namespace caf::detail {
class pollset_updater; class pollset_updater;
} // namespace caf::detail } // namespace caf::detail
namespace caf::net::lp {
class client;
class frame;
class framing;
class lower_layer;
class server;
class upper_layer;
} // namespace caf::net::lp
namespace caf::net::web_socket {
class client;
class frame;
class framing;
class lower_layer;
class server;
class upper_layer;
template <class Trait, class... Ts>
class server_factory;
enum class status : uint16_t;
} // namespace caf::net::web_socket
namespace caf::net::http {
class header;
class lower_layer;
class server;
class upper_layer;
using header_fields_map
= unordered_flat_map<std::string_view, std::string_view>;
enum class method : uint8_t;
enum class status : uint16_t;
} // namespace caf::net::http
namespace caf::net::ssl {
class acceptor;
class connection;
class context;
class transport;
enum class dtls;
enum class errc : uint8_t;
enum class format;
enum class tls;
} // namespace caf::net::ssl
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/fwd.hpp"
#include <string_view>
namespace caf::net::http {
class header;
class lower_layer;
class server;
class upper_layer;
using header_fields_map
= unordered_flat_map<std::string_view, std::string_view>;
enum class method : uint8_t;
enum class status : uint16_t;
} // namespace caf::net::http
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/generic_lower_layer.hpp" #include "caf/net/generic_lower_layer.hpp"
#include "caf/net/http/fwd.hpp"
#include <string_view> #include <string_view>
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "caf/default_enum_inspect.hpp" #include "caf/default_enum_inspect.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/net/http/fwd.hpp"
#include <cstdint> #include <cstdint>
#include <string> #include <string>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "caf/async/promise.hpp" #include "caf/async/promise.hpp"
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/net/http/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/http/header.hpp" #include "caf/net/http/header.hpp"
#include "caf/net/http/response.hpp" #include "caf/net/http/response.hpp"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "caf/byte_buffer.hpp" #include "caf/byte_buffer.hpp"
#include "caf/default_enum_inspect.hpp" #include "caf/default_enum_inspect.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/net/http/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/span.hpp" #include "caf/span.hpp"
#include "caf/unordered_flat_map.hpp" #include "caf/unordered_flat_map.hpp"
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "caf/async/blocking_producer.hpp" #include "caf/async/blocking_producer.hpp"
#include "caf/defaults.hpp" #include "caf/defaults.hpp"
#include "caf/detail/accept_handler.hpp" #include "caf/detail/accept_handler.hpp"
#include "caf/detail/binary_flow_bridge.hpp"
#include "caf/detail/connection_factory.hpp" #include "caf/detail/connection_factory.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "caf/default_enum_inspect.hpp" #include "caf/default_enum_inspect.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/net/http/fwd.hpp"
#include "caf/string_view.hpp" #include "caf/string_view.hpp"
#include <cstdint> #include <cstdint>
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/generic_upper_layer.hpp" #include "caf/net/generic_upper_layer.hpp"
#include "caf/net/http/fwd.hpp"
namespace caf::net::http { namespace caf::net::http {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#pragma once #pragma once
#include "caf/async/spsc_buffer.hpp" #include "caf/async/spsc_buffer.hpp"
#include "caf/detail/binary_flow_bridge.hpp" #include "caf/detail/lp_flow_bridge.hpp"
#include "caf/disposable.hpp" #include "caf/disposable.hpp"
#include "caf/net/checked_socket.hpp" #include "caf/net/checked_socket.hpp"
#include "caf/net/dsl/client_factory_base.hpp" #include "caf/net/dsl/client_factory_base.hpp"
...@@ -24,9 +24,9 @@ namespace caf::detail { ...@@ -24,9 +24,9 @@ namespace caf::detail {
/// Specializes the WebSocket flow bridge for the server side. /// Specializes the WebSocket flow bridge for the server side.
template <class Trait> template <class Trait>
class lp_client_flow_bridge : public binary_flow_bridge<Trait> { class lp_client_flow_bridge : public lp_flow_bridge<Trait> {
public: public:
using super = binary_flow_bridge<Trait>; using super = lp_flow_bridge<Trait>;
// We consume the output type of the application. // We consume the output type of the application.
using pull_t = async::consumer_resource<typename Trait::output_type>; using pull_t = async::consumer_resource<typename Trait::output_type>;
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
push_.abort(err); push_.abort(err);
} }
error start(net::binary::lower_layer* down_ptr) override { error start(net::lp::lower_layer* down_ptr) override {
super::down_ = down_ptr; super::down_ = down_ptr;
return super::init(std::move(pull_), std::move(push_)); return super::init(std::move(pull_), std::move(push_));
} }
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
#include "caf/async/spsc_buffer.hpp" #include "caf/async/spsc_buffer.hpp"
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/net/binary/fwd.hpp" #include "caf/net/fwd.hpp"
#include <string_view> #include <string_view>
#include <vector> #include <vector>
namespace caf::net::binary { namespace caf::net::lp {
/// A default trait type for binary protocols that uses @ref frame as both input /// A default trait type for binary protocols that uses @ref frame as both input
/// and output types and provides async::consumer_resource and /// and output types and provides async::consumer_resource and
...@@ -56,4 +56,4 @@ public: ...@@ -56,4 +56,4 @@ public:
error last_error(); error last_error();
}; };
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "caf/raise_error.hpp" #include "caf/raise_error.hpp"
#include "caf/type_id.hpp" #include "caf/type_id.hpp"
namespace caf::net::binary { namespace caf::net::lp {
/// An implicitly shared type for binary data frames. /// An implicitly shared type for binary data frames.
class CAF_NET_EXPORT frame { class CAF_NET_EXPORT frame {
...@@ -74,4 +74,4 @@ private: ...@@ -74,4 +74,4 @@ private:
intrusive_ptr<web_socket::frame::data> data_; intrusive_ptr<web_socket::frame::data> data_;
}; };
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -8,15 +8,12 @@ ...@@ -8,15 +8,12 @@
#include "caf/async/spsc_buffer.hpp" #include "caf/async/spsc_buffer.hpp"
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/cow_tuple.hpp" #include "caf/cow_tuple.hpp"
#include "caf/detail/accept_handler.hpp"
#include "caf/detail/binary_flow_bridge.hpp"
#include "caf/detail/connection_factory.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/disposable.hpp" #include "caf/disposable.hpp"
#include "caf/net/binary/default_trait.hpp" #include "caf/net/lp/default_trait.hpp"
#include "caf/net/binary/frame.hpp" #include "caf/net/lp/frame.hpp"
#include "caf/net/binary/lower_layer.hpp" #include "caf/net/lp/lower_layer.hpp"
#include "caf/net/binary/upper_layer.hpp" #include "caf/net/lp/upper_layer.hpp"
#include "caf/net/middleman.hpp" #include "caf/net/middleman.hpp"
#include "caf/net/octet_stream/upper_layer.hpp" #include "caf/net/octet_stream/upper_layer.hpp"
...@@ -33,11 +30,11 @@ namespace caf::net::lp { ...@@ -33,11 +30,11 @@ namespace caf::net::lp {
/// maximum size of INT32_MAX. This limitation comes from the POSIX API (recv) /// maximum size of INT32_MAX. This limitation comes from the POSIX API (recv)
/// on 32-bit platforms. /// on 32-bit platforms.
class CAF_NET_EXPORT framing : public octet_stream::upper_layer, class CAF_NET_EXPORT framing : public octet_stream::upper_layer,
public binary::lower_layer { public lp::lower_layer {
public: public:
// -- member types ----------------------------------------------------------- // -- member types -----------------------------------------------------------
using upper_layer_ptr = std::unique_ptr<binary::upper_layer>; using upper_layer_ptr = std::unique_ptr<lp::upper_layer>;
// -- constants -------------------------------------------------------------- // -- constants --------------------------------------------------------------
...@@ -67,7 +64,7 @@ public: ...@@ -67,7 +64,7 @@ public:
bool done_sending() override; bool done_sending() override;
// -- implementation of binary::lower_layer ---------------------------------- // -- implementation of lp::lower_layer ----------------------------------
bool can_send_more() const noexcept override; bool can_send_more() const noexcept override;
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/binary/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/generic_lower_layer.hpp" #include "caf/net/generic_lower_layer.hpp"
namespace caf::net::binary { namespace caf::net::lp {
/// Provides access to a resource that operates on the granularity of binary /// Provides access to a resource that operates on the granularity of binary
/// messages. /// messages.
...@@ -41,4 +41,4 @@ public: ...@@ -41,4 +41,4 @@ public:
virtual bool end_message() = 0; virtual bool end_message() = 0;
}; };
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "caf/async/blocking_producer.hpp" #include "caf/async/blocking_producer.hpp"
#include "caf/defaults.hpp" #include "caf/defaults.hpp"
#include "caf/detail/accept_handler.hpp" #include "caf/detail/accept_handler.hpp"
#include "caf/detail/binary_flow_bridge.hpp"
#include "caf/detail/connection_factory.hpp" #include "caf/detail/connection_factory.hpp"
#include "caf/detail/lp_flow_bridge.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/checked_socket.hpp" #include "caf/net/checked_socket.hpp"
#include "caf/net/dsl/server_factory_base.hpp" #include "caf/net/dsl/server_factory_base.hpp"
...@@ -29,9 +29,9 @@ namespace caf::detail { ...@@ -29,9 +29,9 @@ namespace caf::detail {
/// Specializes the length-prefix flow bridge for the server side. /// Specializes the length-prefix flow bridge for the server side.
template <class Trait> template <class Trait>
class lp_server_flow_bridge : public binary_flow_bridge<Trait> { class lp_server_flow_bridge : public lp_flow_bridge<Trait> {
public: public:
using super = binary_flow_bridge<Trait>; using super = lp_flow_bridge<Trait>;
using input_type = typename Trait::input_type; using input_type = typename Trait::input_type;
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
return std::make_unique<lp_server_flow_bridge>(mpx, std::move(producer)); return std::make_unique<lp_server_flow_bridge>(mpx, std::move(producer));
} }
error start(net::binary::lower_layer* down_ptr) override { error start(net::lp::lower_layer* down_ptr) override {
CAF_ASSERT(down_ptr != nullptr); CAF_ASSERT(down_ptr != nullptr);
super::down_ = down_ptr; super::down_ = down_ptr;
auto [app_pull, lp_push] = async::make_spsc_buffer_resource<input_type>(); auto [app_pull, lp_push] = async::make_spsc_buffer_resource<input_type>();
......
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/binary/fwd.hpp"
#include "caf/net/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/generic_upper_layer.hpp" #include "caf/net/generic_upper_layer.hpp"
namespace caf::net::binary { namespace caf::net::lp {
/// Consumes binary messages from the lower layer. /// Consumes lp messages from the lower layer.
class CAF_NET_EXPORT upper_layer : public generic_upper_layer { class CAF_NET_EXPORT upper_layer : public generic_upper_layer {
public: public:
virtual ~upper_layer(); virtual ~upper_layer();
...@@ -30,4 +29,4 @@ public: ...@@ -30,4 +29,4 @@ public:
[[nodiscard]] virtual ptrdiff_t consume(byte_span payload) = 0; [[nodiscard]] virtual ptrdiff_t consume(byte_span payload) = 0;
}; };
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -61,12 +61,12 @@ private: ...@@ -61,12 +61,12 @@ private:
intrusive_ptr<config_type> config_; intrusive_ptr<config_type> config_;
}; };
template <class Trait = binary::default_trait> template <class Trait = lp::default_trait>
with_t<Trait> with(actor_system& sys) { with_t<Trait> with(actor_system& sys) {
return with_t<Trait>{multiplexer::from(sys)}; return with_t<Trait>{multiplexer::from(sys)};
} }
template <class Trait = binary::default_trait> template <class Trait = lp::default_trait>
with_t<Trait> with(multiplexer* mpx) { with_t<Trait> with(multiplexer* mpx) {
return with_t<Trait>{mpx}; return with_t<Trait>{mpx};
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#pragma once #pragma once
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/http/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/http/upper_layer.hpp" #include "caf/net/http/upper_layer.hpp"
#include "caf/telemetry/collector/prometheus.hpp" #include "caf/telemetry/collector/prometheus.hpp"
#include "caf/telemetry/importer/process.hpp" #include "caf/telemetry/importer/process.hpp"
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/ssl/errc.hpp" #include "caf/net/ssl/errc.hpp"
#include "caf/net/ssl/fwd.hpp"
#include "caf/net/stream_socket.hpp" #include "caf/net/stream_socket.hpp"
#include <cstddef> #include <cstddef>
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/net/dsl/arg.hpp" #include "caf/net/dsl/arg.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/socket_guard.hpp" #include "caf/net/socket_guard.hpp"
#include "caf/net/ssl/dtls.hpp" #include "caf/net/ssl/dtls.hpp"
#include "caf/net/ssl/format.hpp" #include "caf/net/ssl/format.hpp"
#include "caf/net/ssl/fwd.hpp"
#include "caf/net/ssl/password.hpp" #include "caf/net/ssl/password.hpp"
#include "caf/net/ssl/tls.hpp" #include "caf/net/ssl/tls.hpp"
#include "caf/net/ssl/verify.hpp" #include "caf/net/ssl/verify.hpp"
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
namespace caf::net::ssl {
class acceptor;
class connection;
class context;
class transport;
enum class dtls;
enum class errc : uint8_t;
enum class format;
enum class tls;
} // namespace caf::net::ssl
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "caf/detail/net_export.hpp" #include "caf/detail/net_export.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/ssl/context.hpp" #include "caf/net/ssl/context.hpp"
#include "caf/net/ssl/fwd.hpp"
#include "caf/net/tcp_accept_socket.hpp" #include "caf/net/tcp_accept_socket.hpp"
#include <variant> #include <variant>
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "caf/cow_tuple.hpp" #include "caf/cow_tuple.hpp"
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/net/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/web_socket/fwd.hpp"
#include <utility> #include <utility>
...@@ -20,9 +19,6 @@ namespace caf::net::web_socket { ...@@ -20,9 +19,6 @@ namespace caf::net::web_socket {
template <class... Ts> template <class... Ts>
class acceptor { class acceptor {
public: public:
template <class Trait>
using impl_type = acceptor_impl<Trait, Ts...>;
template <class Trait> template <class Trait>
using server_factory_type = server_factory<Trait, Ts...>; using server_factory_type = server_factory<Trait, Ts...>;
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
namespace caf::detail {
template <class, class...>
class ws_flow_connector_request_impl;
} // namespace caf::detail
namespace caf::net::web_socket {
template <class... Ts>
class acceptor;
template <class Trait, class... Ts>
class acceptor_impl;
template <class Trait, class... Ts>
class server_factory;
class frame;
class framing;
class lower_layer;
class server;
class upper_layer;
enum class status : uint16_t;
} // namespace caf::net::web_socket
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/detail/type_traits.hpp" #include "caf/detail/type_traits.hpp"
#include "caf/net/dsl/server_factory_base.hpp" #include "caf/net/dsl/server_factory_base.hpp"
#include "caf/net/http/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/web_socket/acceptor.hpp" #include "caf/net/web_socket/acceptor.hpp"
#include "caf/net/web_socket/server_factory.hpp" #include "caf/net/web_socket/server_factory.hpp"
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/net/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/generic_lower_layer.hpp" #include "caf/net/generic_lower_layer.hpp"
#include "caf/net/web_socket/fwd.hpp"
#include <string_view> #include <string_view>
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/callback.hpp" #include "caf/callback.hpp"
#include "caf/defaults.hpp" #include "caf/defaults.hpp"
#include "caf/detail/accept_handler.hpp" #include "caf/detail/accept_handler.hpp"
#include "caf/detail/binary_flow_bridge.hpp"
#include "caf/detail/connection_factory.hpp" #include "caf/detail/connection_factory.hpp"
#include "caf/detail/ws_flow_bridge.hpp" #include "caf/detail/ws_flow_bridge.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/net/fwd.hpp" #include "caf/net/fwd.hpp"
#include "caf/net/generic_upper_layer.hpp" #include "caf/net/generic_upper_layer.hpp"
#include "caf/net/http/header.hpp" #include "caf/net/http/header.hpp"
#include "caf/net/web_socket/fwd.hpp"
namespace caf::net::web_socket { namespace caf::net::web_socket {
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// the main distribution directory for license terms and copyright or visit // the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE. // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/net/binary/default_trait.hpp" #include "caf/net/lp/default_trait.hpp"
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/logger.hpp" #include "caf/logger.hpp"
#include "caf/net/binary/frame.hpp" #include "caf/net/lp/frame.hpp"
#include "caf/sec.hpp" #include "caf/sec.hpp"
namespace caf::net::binary { namespace caf::net::lp {
bool default_trait::convert(const output_type& x, byte_buffer& bytes) { bool default_trait::convert(const output_type& x, byte_buffer& bytes) {
auto src = x.bytes(); auto src = x.bytes();
...@@ -23,8 +23,8 @@ bool default_trait::convert(const_byte_span bytes, input_type& x) { ...@@ -23,8 +23,8 @@ bool default_trait::convert(const_byte_span bytes, input_type& x) {
} }
error default_trait::last_error() { error default_trait::last_error() {
CAF_LOG_ERROR("default_trait::last_error called"); CAF_LOG_ERROR("lp::default_trait::last_error called");
return {sec::logic_error}; return {sec::logic_error};
} }
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// the main distribution directory for license terms and copyright or visit // the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE. // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/net/binary/frame.hpp" #include "caf/net/lp/frame.hpp"
#include <cstring> #include <cstring>
#include <new> #include <new>
#include <numeric> #include <numeric>
namespace caf::net::binary { namespace caf::net::lp {
namespace { namespace {
...@@ -36,4 +36,4 @@ void frame::init(size_t payload_size, Args&&... args) { ...@@ -36,4 +36,4 @@ void frame::init(size_t payload_size, Args&&... args) {
data_.reset(new (vptr) data_t(std::forward<Args>(args)...), false); data_.reset(new (vptr) data_t(std::forward<Args>(args)...), false);
} }
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -80,7 +80,7 @@ bool framing::done_sending() { ...@@ -80,7 +80,7 @@ bool framing::done_sending() {
return up_->done_sending(); return up_->done_sending();
} }
// -- implementation of binary::lower_layer ------------------------------------ // -- implementation of lp::lower_layer ----------------------------------------
bool framing::can_send_more() const noexcept { bool framing::can_send_more() const noexcept {
return down_->can_send_more(); return down_->can_send_more();
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// the main distribution directory for license terms and copyright or visit // the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE. // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/net/binary/lower_layer.hpp" #include "caf/net/lp/lower_layer.hpp"
namespace caf::net::binary { namespace caf::net::lp {
lower_layer::~lower_layer() { lower_layer::~lower_layer() {
// nop // nop
} }
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// the main distribution directory for license terms and copyright or visit // the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE. // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/net/binary/upper_layer.hpp" #include "caf/net/lp/upper_layer.hpp"
namespace caf::net::binary { namespace caf::net::lp {
upper_layer::~upper_layer() { upper_layer::~upper_layer() {
// nop // nop
} }
} // namespace caf::net::binary } // namespace caf::net::lp
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include "caf/byte_buffer.hpp" #include "caf/byte_buffer.hpp"
#include "caf/byte_span.hpp" #include "caf/byte_span.hpp"
#include "caf/detail/network_order.hpp" #include "caf/detail/network_order.hpp"
#include "caf/net/binary/frame.hpp" #include "caf/net/lp/frame.hpp"
#include "caf/net/binary/lower_layer.hpp" #include "caf/net/lp/lower_layer.hpp"
#include "caf/net/binary/upper_layer.hpp" #include "caf/net/lp/upper_layer.hpp"
#include "caf/net/multiplexer.hpp" #include "caf/net/multiplexer.hpp"
#include "caf/net/octet_stream/transport.hpp" #include "caf/net/octet_stream/transport.hpp"
#include "caf/net/socket_guard.hpp" #include "caf/net/socket_guard.hpp"
...@@ -38,7 +38,7 @@ using string_list = std::vector<std::string>; ...@@ -38,7 +38,7 @@ using string_list = std::vector<std::string>;
using shared_string_list = std::shared_ptr<string_list>; using shared_string_list = std::shared_ptr<string_list>;
template <bool EnableSuspend> template <bool EnableSuspend>
class app_t : public net::binary::upper_layer { class app_t : public net::lp::upper_layer {
public: public:
app_t(async::execution_context_ptr loop, shared_string_list ls_ptr) app_t(async::execution_context_ptr loop, shared_string_list ls_ptr)
: loop(std::move(loop)), inputs(std::move(ls_ptr)) { : loop(std::move(loop)), inputs(std::move(ls_ptr)) {
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
return std::make_unique<app_t>(std::move(loop), std::move(inputs)); return std::make_unique<app_t>(std::move(loop), std::move(inputs));
} }
caf::error start(net::binary::lower_layer* down_ptr) override { caf::error start(net::lp::lower_layer* down_ptr) override {
// Start reading immediately. // Start reading immediately.
down = down_ptr; down = down_ptr;
down->request_messages(); down->request_messages();
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
async::execution_context_ptr loop; async::execution_context_ptr loop;
net::binary::lower_layer* down = nullptr; net::lp::lower_layer* down = nullptr;
shared_string_list inputs; shared_string_list inputs;
}; };
...@@ -257,17 +257,17 @@ SCENARIO("lp::with(...).connect(...) translates between flows and socket I/O") { ...@@ -257,17 +257,17 @@ SCENARIO("lp::with(...).connect(...) translates between flows and socket I/O") {
MESSAGE("flow aborted: " << what); MESSAGE("flow aborted: " << what);
}) })
.do_on_complete([] { MESSAGE("flow completed"); }) .do_on_complete([] { MESSAGE("flow completed"); })
.do_on_next([buf](const net::binary::frame& x) { .do_on_next([buf](const net::lp::frame& x) {
std::string str; std::string str;
for (auto val : x.bytes()) for (auto val : x.bytes())
str.push_back(static_cast<char>(val)); str.push_back(static_cast<char>(val));
buf->push_back(std::move(str)); buf->push_back(std::move(str));
}) })
.map([](const net::binary::frame& x) { .map([](const net::lp::frame& x) {
std::string response = "ok "; std::string response = "ok ";
for (auto val : x.bytes()) for (auto val : x.bytes())
response.push_back(static_cast<char>(val)); response.push_back(static_cast<char>(val));
return net::binary::frame{as_bytes(make_span(response))}; return net::lp::frame{as_bytes(make_span(response))};
}) })
.subscribe(push); .subscribe(push);
}); });
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// the main distribution directory for license terms and copyright or visit // the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE. // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#define CAF_SUITE net.binary.frame #define CAF_SUITE net.lp.frame
#include "caf/net/binary/frame.hpp" #include "caf/net/lp/frame.hpp"
#include "net-test.hpp" #include "net-test.hpp"
...@@ -25,7 +25,7 @@ std::vector<std::byte> to_vec(span<const T> values) { ...@@ -25,7 +25,7 @@ std::vector<std::byte> to_vec(span<const T> values) {
} // namespace } // namespace
TEST_CASE("default construction") { TEST_CASE("default construction") {
net::binary::frame uut; net::lp::frame uut;
CHECK(!uut); CHECK(!uut);
CHECK(uut.empty()); CHECK(uut.empty());
CHECK(uut.bytes().empty()); CHECK(uut.bytes().empty());
...@@ -34,7 +34,7 @@ TEST_CASE("default construction") { ...@@ -34,7 +34,7 @@ TEST_CASE("default construction") {
TEST_CASE("construction from a single buffer") { TEST_CASE("construction from a single buffer") {
auto buf = to_byte_buf(1, 2, 3); auto buf = to_byte_buf(1, 2, 3);
auto uut = net::binary::frame{make_span(buf)}; auto uut = net::lp::frame{make_span(buf)};
CHECK(static_cast<bool>(uut)); CHECK(static_cast<bool>(uut));
CHECK(!uut.empty()); CHECK(!uut.empty());
CHECK(!uut.bytes().empty()); CHECK(!uut.bytes().empty());
...@@ -48,7 +48,7 @@ TEST_CASE("construction from multiple buffers") { ...@@ -48,7 +48,7 @@ TEST_CASE("construction from multiple buffers") {
auto buf2 = to_byte_buf(); auto buf2 = to_byte_buf();
auto buf3 = to_byte_buf(3, 4, 5); auto buf3 = to_byte_buf(3, 4, 5);
auto buf4 = to_byte_buf(1, 2, 3, 4, 5); auto buf4 = to_byte_buf(1, 2, 3, 4, 5);
auto uut = net::binary::frame::from_buffers(buf1, buf2, buf3); auto uut = net::lp::frame::from_buffers(buf1, buf2, buf3);
CHECK(static_cast<bool>(uut)); CHECK(static_cast<bool>(uut));
CHECK(!uut.empty()); CHECK(!uut.empty());
CHECK(!uut.bytes().empty()); CHECK(!uut.bytes().empty());
...@@ -59,8 +59,8 @@ TEST_CASE("construction from multiple buffers") { ...@@ -59,8 +59,8 @@ TEST_CASE("construction from multiple buffers") {
TEST_CASE("copying, moving and swapping") { TEST_CASE("copying, moving and swapping") {
auto buf = to_byte_buf(1, 2, 3); auto buf = to_byte_buf(1, 2, 3);
auto uut1 = net::binary::frame{}; auto uut1 = net::lp::frame{};
auto uut2 = net::binary::frame{make_span(buf)}; auto uut2 = net::lp::frame{make_span(buf)};
auto uut3 = uut1; auto uut3 = uut1;
auto uut4 = uut2; auto uut4 = uut2;
CHECK_EQ(uut1.bytes().data(), uut3.bytes().data()); CHECK_EQ(uut1.bytes().data(), uut3.bytes().data());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment