diff options
author | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-08-08 18:13:31 +0200 |
---|---|---|
committer | Claudius 'keldu' Holeksa <mail@keldu.de> | 2024-08-08 18:13:31 +0200 |
commit | a64b8346f39a34ef811b679bbed8131e2098e546 (patch) | |
tree | c79ce71a1d43eb69d8d285737a116a26ed429ba7 /modules/io_codec | |
parent | 139b727e1b60bb309d40260b9577dcec7ce3bf53 (diff) |
wip
Diffstat (limited to 'modules/io_codec')
-rw-r--r-- | modules/io_codec/examples/peer_echo_client.cpp | 5 | ||||
-rw-r--r-- | modules/io_codec/examples/peer_echo_server.cpp | 6 |
2 files changed, 6 insertions, 5 deletions
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"<<std::endl; - data<sch::Echo> nat_resp; echo_peer_stream_p.second.then([&](auto simp_resp){ + data<sch::Echo> 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<void>{ + 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<void>{ return make_error<err::critical>("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<sch::Echo, sch::Echo, trans::FixedLength<8u>, encode::KelSimple, ring_buffer>(std::move(echo_stream)); std::cout<<"Got client"<<std::endl; + auto peer_str = echo_peer_stream_p.first.get(); - echo_peer_stream_p.second.then([&](auto simp_resp) -> error_or<void> { + echo_peer_stream_p.second.then([&,peer_str](auto simp_resp) -> error_or<void> { std::cout<<"Request\n"; data<sch::Echo> nat_resp; { @@ -76,7 +77,7 @@ int main(){ std::cout<<std::endl; { - auto eo_send = echo_peer_stream_p.first->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<void>{ return make_error<err::critical>("Destroy pipeline on purpose :>"); }).detach(); |