From 5f946d3dba74a7d3bc12bc75c4e7e7ed58805d58 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Fri, 19 Jul 2024 19:15:32 +0200 Subject: wip --- modules/io_codec/examples/echo.hpp | 9 +++++++++ modules/io_codec/examples/peer_echo_client.cpp | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'modules/io_codec/examples') diff --git a/modules/io_codec/examples/echo.hpp b/modules/io_codec/examples/echo.hpp index 71be1a0..84b9b31 100644 --- a/modules/io_codec/examples/echo.hpp +++ b/modules/io_codec/examples/echo.hpp @@ -3,6 +3,15 @@ #include #include +#include +#include + +namespace sch { +using namespace saw::schema; + +using Echo = String; +} + namespace saw { constexpr std::string echo_address = "::1"; constexpr uint16_t echo_port = 4322; diff --git a/modules/io_codec/examples/peer_echo_client.cpp b/modules/io_codec/examples/peer_echo_client.cpp index e8c8f82..f1836e4 100644 --- a/modules/io_codec/examples/peer_echo_client.cpp +++ b/modules/io_codec/examples/peer_echo_client.cpp @@ -5,6 +5,8 @@ #include int main(){ + using namespace saw; + auto eo_aio = saw::setup_async_io(); if(eo_aio.is_error()){ auto& err = eo_aio.get_error(); @@ -29,10 +31,12 @@ int main(){ return -1; } auto& addr = eo_addr.get_value(); - saw::own echo_stream = nullptr; - network.connect(*addr).then([&echo_stream](saw::own client){ - echo_stream = saw::heap(std::move(client)); + network.connect(*addr).then([](saw::own client){ + auto echo_stream = saw::heap(std::move(client)); + auto echo_peer_stream_p = saw::new_streaming_io_peer(std::move(echo_stream)); + + echo_peer_stream_p.first->on_read_disconnected().attach(std::move(echo_peer_stream_p.first)).detach(); }).detach(); return 0; -- cgit v1.2.3