diff --git a/library/include/larra/client/client.hpp b/library/include/larra/client/client.hpp index b1dd348..ff29035 100644 --- a/library/include/larra/client/client.hpp +++ b/library/include/larra/client/client.hpp @@ -314,9 +314,6 @@ struct ClientCreateVisitor { }; auto GetStartStreamIndex(auto& socket, boost::asio::streambuf& streambuf) -> boost::asio::awaitable { - auto buf = streambuf.prepare(4096); // NOLINT - std::size_t n = co_await socket.async_read_some(buf, boost::asio::use_awaitable); - streambuf.commit(n); auto splited = Splitter{GetEnumerated(streambuf)}; using It = decltype(splited.begin()); // clang-format off @@ -327,9 +324,14 @@ struct ClientCreateVisitor { .transform([](auto value) -> boost::asio::awaitable { auto [n, _] = *value; co_return n; - }) - .or_else([&] -> std::optional> { - return this->GetStartStreamIndex(socket, streambuf); + }) // NOLINTNEXTLINE + .or_else([&] { // NOLINTNEXTLINE + return std::optional{[](auto self, auto& socket, auto& streambuf) -> boost::asio::awaitable { + auto buf = streambuf.prepare(4096); // NOLINT + std::size_t n = co_await socket.async_read_some(buf, boost::asio::use_awaitable); + streambuf.commit(n); + co_return co_await self->GetStartStreamIndex(socket, streambuf); + }(this, socket, streambuf)}; }) .value(); // clang-format on