summaryrefslogtreecommitdiff
path: root/modules/io_codec
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-07 17:37:47 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-07 17:37:47 +0200
commit03ed2a0fe01704f9c34b44e0963da82f894d8968 (patch)
treea7f5a9b9a9bed4c0c0efbdc500da3abb9deb4934 /modules/io_codec
parenta51d012bb1e7d34ff5e27bebccd8026bc731515c (diff)
wip
Diffstat (limited to 'modules/io_codec')
-rw-r--r--modules/io_codec/c++/io_peer.tmpl.hpp12
-rw-r--r--modules/io_codec/examples/echo.hpp2
-rw-r--r--modules/io_codec/examples/peer_echo_client.cpp23
3 files changed, 20 insertions, 17 deletions
diff --git a/modules/io_codec/c++/io_peer.tmpl.hpp b/modules/io_codec/c++/io_peer.tmpl.hpp
index 4deabd3..faf8c7b 100644
--- a/modules/io_codec/c++/io_peer.tmpl.hpp
+++ b/modules/io_codec/c++/io_peer.tmpl.hpp
@@ -91,7 +91,17 @@ error_or<void> streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentE
msg) {
bool restart_write = (out_buffer_.read_segment_length() == 0u);
- auto eov = out_buffer_.write_from(msg.get_buffer());
+ auto& msg_buff = msg.get_buffer();
+ {
+ auto eov = in_codec_.wrap(out_buffer_, msg_buff);
+ if(eov.is_error()){
+ auto& err = eov.get_error();
+ return std::move(err);
+ }
+ // auto& len_val = eov.get_value();
+ }
+
+ auto eov = out_buffer_.write_from(msg_buff);
if (eov.is_error()) {
auto& err = eov.get_error();
return std::move(err);
diff --git a/modules/io_codec/examples/echo.hpp b/modules/io_codec/examples/echo.hpp
index 84b9b31..04819b0 100644
--- a/modules/io_codec/examples/echo.hpp
+++ b/modules/io_codec/examples/echo.hpp
@@ -13,6 +13,6 @@ using Echo = String;
}
namespace saw {
-constexpr std::string echo_address = "::1";
+constexpr std::string echo_address = "127.0.0.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 d2c4351..90f9627 100644
--- a/modules/io_codec/examples/peer_echo_client.cpp
+++ b/modules/io_codec/examples/peer_echo_client.cpp
@@ -35,16 +35,8 @@ int main(){
auto& addr = eo_addr.get_value();
data<sch::Echo> nat_echo{"hello"};
- data<sch::Echo, encode::KelSimple> simple_echo;
codec<sch::Echo, encode::KelSimple> simple_codec;
- {
- auto eov = simple_codec.encode(nat_echo, simple_echo);
- if(eov.is_error()){
- return -1;
- }
- }
-
network.connect(*addr).then([&](saw::own<saw::io_stream> client){
if(!client){
return;
@@ -54,6 +46,14 @@ 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<<"Connected"<<std::endl;
+
+ data<sch::Echo, encode::KelSimple> simple_echo;
+ {
+ auto eov = simple_codec.encode(nat_echo, simple_echo);
+ if(eov.is_error()){
+ return ;
+ }
+ }
{
auto eo_send = echo_peer_stream_p.first->send(std::move(simple_echo));
if(eo_send.is_error()){
@@ -61,13 +61,6 @@ int main(){
}
}
std::cout<<"Sent data"<<std::endl;
- {
- simple_echo = {};
- auto eov = simple_codec.encode(nat_echo, simple_echo);
- if(eov.is_error()){
- return ;
- }
- }
data<sch::Echo> nat_resp;
echo_peer_stream_p.second.then([&](auto simp_resp){