summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-07 17:50:30 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-08-07 17:50:30 +0200
commit8fd1eaa255ff71e325eded82740e0942494f7264 (patch)
treeae793b1754cd82e98442a3a8b99174f93cb8acb2
parent03ed2a0fe01704f9c34b44e0963da82f894d8968 (diff)
wip debug
-rw-r--r--modules/io_codec/c++/io_peer.tmpl.hpp12
-rw-r--r--modules/io_codec/examples/peer_echo_server.cpp6
2 files changed, 16 insertions, 2 deletions
diff --git a/modules/io_codec/c++/io_peer.tmpl.hpp b/modules/io_codec/c++/io_peer.tmpl.hpp
index faf8c7b..a9f942d 100644
--- a/modules/io_codec/c++/io_peer.tmpl.hpp
+++ b/modules/io_codec/c++/io_peer.tmpl.hpp
@@ -52,6 +52,7 @@ streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentEncoding,
}
auto& len_val = eo_len.get_value();
in_buffer_.write_advance(len_val);
+ in_buff->write_advance(len_val);
data<Incoming, ContentEncoding> in_data{std::move(in_buff)};
incoming_feeder_->feed(std::move(in_data));
@@ -84,13 +85,20 @@ streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentEncoding,
io_stream_->read(&in_buffer_.write(), 1, in_buffer_.write_segment_length());
}
+}
+#include <iostream>
+namespace saw {
+
template <typename Incoming, typename Outgoing, typename TransportEncoding,
typename ContentEncoding, typename BufferT>
error_or<void> streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentEncoding,
BufferT>::send(data<Outgoing, ContentEncoding>
msg) {
+ std::cout<<"O: "<<out_buffer_.read_segment_length()<<std::endl;
bool restart_write = (out_buffer_.read_segment_length() == 0u);
+ std::cout<<"A: "<<out_buffer_.read_segment_length()<<std::endl;
+
auto& msg_buff = msg.get_buffer();
{
auto eov = in_codec_.wrap(out_buffer_, msg_buff);
@@ -100,6 +108,7 @@ error_or<void> streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentE
}
// auto& len_val = eov.get_value();
}
+ std::cout<<"B"<<std::endl;
auto eov = out_buffer_.write_from(msg_buff);
if (eov.is_error()) {
@@ -108,11 +117,14 @@ error_or<void> streaming_io_peer<Incoming, Outgoing, TransportEncoding, ContentE
}
auto& len_val = eov.get_value();
out_buffer_.write_advance(len_val);
+ std::cout<<"C"<<std::endl;
if (restart_write && out_buffer_.read_segment_length() > 0u) {
+ std::cout<<"D"<<std::endl;
io_stream_->write(&out_buffer_.read(),
out_buffer_.read_segment_length());
}
+ std::cout<<"E"<<std::endl;
return void_t{};
}
diff --git a/modules/io_codec/examples/peer_echo_server.cpp b/modules/io_codec/examples/peer_echo_server.cpp
index a949ff5..279db92 100644
--- a/modules/io_codec/examples/peer_echo_server.cpp
+++ b/modules/io_codec/examples/peer_echo_server.cpp
@@ -58,16 +58,18 @@ int main(){
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, trans::FixedLength<8u>, encode::KelSimple, ring_buffer>(std::move(echo_stream));
+ std::cout<<"Got client"<<std::endl;
- echo_peer_stream_p.second.then([&](auto simp_resp) -> error_or<void>{
+ echo_peer_stream_p.second.then([&](auto simp_resp) -> error_or<void> {
+ std::cout<<"Request\n";
data<sch::Echo> nat_resp;
{
auto eov = simple_codec.decode(simp_resp, nat_resp);
if(eov.is_error()){
+ std::cerr<<"Failed to decode"<<std::endl;
return eov;
}
}
- std::cout<<"Request:\n";
for(uint64_t i = 0u; i < nat_resp.size(); ++i){
std::cout<<nat_resp.at(i);
}