summaryrefslogtreecommitdiff
path: root/modules/io_codec
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-07-19 19:15:32 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-07-19 19:15:32 +0200
commit5f946d3dba74a7d3bc12bc75c4e7e7ed58805d58 (patch)
tree9f0a23255734edaa60fdd254848972884b65edab /modules/io_codec
parentd37e2449e0c5f44b4d10ecd6c99841a9b3c4b582 (diff)
wip
Diffstat (limited to 'modules/io_codec')
-rw-r--r--modules/io_codec/c++/io_peer.tmpl.hpp4
-rw-r--r--modules/io_codec/examples/echo.hpp9
-rw-r--r--modules/io_codec/examples/peer_echo_client.cpp10
3 files changed, 18 insertions, 5 deletions
diff --git a/modules/io_codec/c++/io_peer.tmpl.hpp b/modules/io_codec/c++/io_peer.tmpl.hpp
index 26793b1..3dc11c8 100644
--- a/modules/io_codec/c++/io_peer.tmpl.hpp
+++ b/modules/io_codec/c++/io_peer.tmpl.hpp
@@ -103,8 +103,8 @@ streaming_io_peer<Incoming, Outgoing, Encoding,
return io_stream_->on_read_disconnected();
}
-template <typename Incoming, typename Outgoing, typename BufferT>
-std::pair<own<streaming_io_peer<Incoming, Outgoing, BufferT>>,
+template <typename Incoming, typename Outgoing, typename Encoding, typename BufferT>
+std::pair<own<streaming_io_peer<Incoming, Outgoing, Encoding, BufferT>>,
conveyor<data<Incoming,Encoding>>>
new_streaming_io_peer(own<async_io_stream> stream) {
auto caf =
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 <string>
#include <cstdint>
+#include <forstio/codec/schema.hpp>
+#include <forstio/codec/simple.hpp>
+
+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 <iostream>
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<saw::async_io_stream> echo_stream = nullptr;
- network.connect(*addr).then([&echo_stream](saw::own<saw::io_stream> client){
- echo_stream = saw::heap<saw::async_io_stream>(std::move(client));
+ network.connect(*addr).then([](saw::own<saw::io_stream> client){
+ auto echo_stream = saw::heap<saw::async_io_stream>(std::move(client));
+ auto echo_peer_stream_p = saw::new_streaming_io_peer<sch::Echo, sch::Echo, encode::KelSimple, ring_buffer>(std::move(echo_stream));
+
+ echo_peer_stream_p.first->on_read_disconnected().attach(std::move(echo_peer_stream_p.first)).detach();
}).detach();
return 0;