Commit 3d945be1 authored by Jakob Otto's avatar Jakob Otto

Port libcaf_net code

parent 50b0ab12
#define CAF_TEST_NO_MAIN
#include "caf/net/test/incubator_test.hpp"
#include "caf/test/unit_test_impl.hpp"
int main(int argc, char** argv) {
caf::init_global_meta_objects<>();
return caf::test::main(argc, argv);
}
\ No newline at end of file
......@@ -125,8 +125,7 @@ public:
// nop
}
static expected<buffer_type> serialize(actor_system& sys,
const type_erased_tuple& x);
static expected<buffer_type> serialize(actor_system& sys, const message& x);
// -- utility functions ------------------------------------------------------
......
......@@ -48,8 +48,7 @@ public:
using maybe_buffer = expected<std::vector<byte>>;
/// A function type for serializing message payloads.
using serialize_fun_type = maybe_buffer (*)(actor_system&,
const type_erased_tuple&);
using serialize_fun_type = maybe_buffer (*)(actor_system&, const message&);
// -- constructors, destructors, and assignment operators --------------------
......
#include "caf/fwd.hpp"
#include "caf/test/dsl.hpp"
#include "caf/type_id.hpp"
#include "caf/typed_actor.hpp"
#include <cstdint>
#include <numeric>
#include <string>
#include <utility>
// -- forward declarations for all unit test suites ----------------------------
// -- type IDs for for all unit test suites ------------------------------------
#define ADD_TYPE_ID(type) CAF_ADD_TYPE_ID(incubator_test, type)
#define ADD_ATOM(atom_name) CAF_ADD_ATOM(incubator_test, atom_name)
CAF_BEGIN_TYPE_ID_BLOCK(incubator_test, caf::first_custom_type_id)
CAF_END_TYPE_ID_BLOCK(incubator_test)
#undef ADD_TYPE_ID
#undef ADD_ATOM
......@@ -39,7 +39,6 @@
#include "caf/sec.hpp"
#include "caf/send.hpp"
#include "caf/string_algorithms.hpp"
#include "caf/type_erased_tuple.hpp"
namespace caf::net::basp {
......@@ -120,10 +119,10 @@ void application::local_actor_down(packet_writer& writer, actor_id id,
}
expected<std::vector<byte>> application::serialize(actor_system& sys,
const type_erased_tuple& x) {
const message& x) {
std::vector<byte> result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......
......@@ -22,7 +22,6 @@
#include "caf/detail/net_syscall.hpp"
#include "caf/detail/socket_sys_includes.hpp"
#include "caf/error.hpp"
#include "caf/make_message.hpp"
#include "caf/message.hpp"
#include "caf/net/socket.hpp"
#include "caf/none.hpp"
......
......@@ -25,10 +25,12 @@
#include "caf/error.hpp"
#include "caf/expected.hpp"
#include "caf/logger.hpp"
#include "caf/make_counted.hpp"
#include "caf/net/operation.hpp"
#include "caf/net/pollset_updater.hpp"
#include "caf/net/socket_manager.hpp"
#include "caf/sec.hpp"
#include "caf/span.hpp"
#include "caf/variant.hpp"
#ifndef CAF_WINDOWS
......
......@@ -26,10 +26,10 @@
#include "caf/detail/socket_sys_aliases.hpp"
#include "caf/detail/socket_sys_includes.hpp"
#include "caf/expected.hpp"
#include "caf/make_message.hpp"
#include "caf/message.hpp"
#include "caf/net/stream_socket.hpp"
#include "caf/sec.hpp"
#include "caf/span.hpp"
#include "caf/variant.hpp"
namespace caf::net {
......
......@@ -27,6 +27,7 @@
#include "caf/ip_endpoint.hpp"
#include "caf/logger.hpp"
#include "caf/net/socket_guard.hpp"
#include "caf/span.hpp"
namespace caf::net {
......
......@@ -166,11 +166,10 @@ public:
CAF_FAIL("handle_error called: " << to_string(sec));
}
static expected<buffer_type> serialize(actor_system& sys,
const type_erased_tuple& x) {
static expected<buffer_type> serialize(actor_system& sys, const message& x) {
buffer_type result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......
......@@ -61,10 +61,10 @@ struct fixture : test_coordinator_fixture<>, host_fixture {
class dummy_application {
public:
static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) {
const message& x) {
std::vector<byte> result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......@@ -117,7 +117,7 @@ public:
using application_type = dummy_application;
static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) {
const message& x) {
return dummy_application::serialize(sys, x);
}
......
......@@ -62,10 +62,10 @@ struct fixture : test_coordinator_fixture<>, host_fixture {
class dummy_application {
public:
static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) {
const message& x) {
std::vector<byte> result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......
......@@ -137,11 +137,10 @@ public:
// nop
}
static expected<buffer_type> serialize(actor_system& sys,
const type_erased_tuple& x) {
static expected<buffer_type> serialize(actor_system& sys, const message& x) {
buffer_type result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......
......@@ -113,10 +113,10 @@ public:
}
static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) {
const message& x) {
std::vector<byte> result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......
......@@ -103,10 +103,10 @@ public:
}
static expected<std::vector<byte>> serialize(actor_system& sys,
const type_erased_tuple& x) {
const message& x) {
std::vector<byte> result;
binary_serializer sink{sys, result};
if (auto err = message::save(sink, x))
if (auto err = x.save(sink))
return err.value();
return result;
}
......
......@@ -92,8 +92,7 @@ public:
rec_buf_->push_back(static_cast<byte>(id_));
}
static expected<buffer_type> serialize(actor_system&,
const type_erased_tuple&) {
static expected<buffer_type> serialize(actor_system&, const message&) {
return buffer_type{};
}
......
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