From a7aadafc8d6842fb960786d4840dc29c490d3071 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 18 Jun 2026 16:42:03 +0200 Subject: lib: add simple echo router --- ttwhy/main.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'ttwhy/main.cpp') diff --git a/ttwhy/main.cpp b/ttwhy/main.cpp index 94c1330..6a813c0 100644 --- a/ttwhy/main.cpp +++ b/ttwhy/main.cpp @@ -3,9 +3,8 @@ #include -#include - import ttwhy; +import ttwhy.routers; auto app(int in, int out, int error) -> asio::awaitable { @@ -17,15 +16,9 @@ auto app(int in, int out, int error) -> asio::awaitable auto output_stream = asio::posix::stream_descriptor{executor, out}; auto error_stream = asio::posix::stream_descriptor{executor, error}; - auto result = - co_await (ttwhy::io::handle_signals(error_stream) || ttwhy::io::echo(input_stream, output_stream, error_stream)); - auto final_error = result.index() == 0 ? std::get<0>(result) : std::get<1>(result); + auto router = ttwhy::routers::echo{input_stream}; - if (final_error && final_error != asio::error::operation_aborted) - { - auto message = std::format("Terminated with error: {}\n", final_error.message()); - co_await asio::async_write(error_stream, asio::buffer(message), asio::use_awaitable); - } + co_await (ttwhy::io::handle_signals(error_stream) || ttwhy::io::read_events(input_stream, router)); } auto main() -> int -- cgit v1.2.3