From a64b8346f39a34ef811b679bbed8131e2098e546 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Thu, 8 Aug 2024 18:13:31 +0200 Subject: wip --- modules/io_codec/examples/peer_echo_client.cpp | 5 +++-- modules/io_codec/examples/peer_echo_server.cpp | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/io_codec/examples') diff --git a/modules/io_codec/examples/peer_echo_client.cpp b/modules/io_codec/examples/peer_echo_client.cpp index 90f9627..d923bc7 100644 --- a/modules/io_codec/examples/peer_echo_client.cpp +++ b/modules/io_codec/examples/peer_echo_client.cpp @@ -62,8 +62,8 @@ int main(){ } std::cout<<"Sent data"< nat_resp; echo_peer_stream_p.second.then([&](auto simp_resp){ + data nat_resp; auto eov = simple_codec.decode(simp_resp, nat_resp); std::cout<<"Answer:\n"; for(uint64_t i = 0u; i < nat_resp.size(); ++i){ @@ -75,7 +75,8 @@ int main(){ keep_running = false; }).detach(); - echo_peer_stream_p.first->on_read_disconnected().attach(std::move(echo_peer_stream_p.first)).then([]() -> error_or{ + auto peer_str = echo_peer_stream_p.first.get(); + peer_str->on_read_disconnected().attach(std::move(echo_peer_stream_p.first)).then([]() -> error_or{ return make_error("Destroy pipeline on purpose :>"); }).detach(); diff --git a/modules/io_codec/examples/peer_echo_server.cpp b/modules/io_codec/examples/peer_echo_server.cpp index 02a7272..87bf721 100644 --- a/modules/io_codec/examples/peer_echo_server.cpp +++ b/modules/io_codec/examples/peer_echo_server.cpp @@ -59,8 +59,9 @@ int main(){ auto echo_peer_stream_p = saw::new_streaming_io_peer, encode::KelSimple, ring_buffer>(std::move(echo_stream)); std::cout<<"Got client"< error_or { + echo_peer_stream_p.second.then([&,peer_str](auto simp_resp) -> error_or { std::cout<<"Request\n"; data nat_resp; { @@ -76,7 +77,7 @@ int main(){ std::cout<send(std::move(simp_resp)); + auto eo_send = peer_str->send(std::move(simp_resp)); if(eo_send.is_error()){ auto& err = eo_send.get_error(); return std::move(err); @@ -85,7 +86,6 @@ int main(){ return make_void(); }).detach(); - auto peer_str = echo_peer_stream_p.first.get(); peer_str->on_read_disconnected().attach(std::move(echo_peer_stream_p.first)).then([]() -> error_or{ return make_error("Destroy pipeline on purpose :>"); }).detach(); -- cgit v1.2.3