1- /* Copyright (c) 2018-2022 Marcelo Zimbres Silva (mzimbres@gmail.com)
1+ /* Copyright (c) 2018-2025 Marcelo Zimbres Silva (mzimbres@gmail.com)
22 *
33 * Distributed under the Boost Software License, Version 1.0. (See
44 * accompanying file LICENSE.txt)
@@ -30,11 +30,9 @@ using boost::asio::consign;
3030using boost::asio::detached;
3131using boost::asio::dynamic_buffer;
3232using boost::asio::redirect_error;
33- using boost::asio::use_awaitable;
3433using boost::redis::config;
3534using boost::redis::connection;
36- using boost::redis::generic_response;
37- using boost::redis::ignore;
35+ using boost::redis::generic_flat_response;
3836using boost::redis::request;
3937using boost::system::error_code;
4038using namespace std ::chrono_literals;
@@ -47,20 +45,24 @@ auto receiver(std::shared_ptr<connection> conn) -> awaitable<void>
4745 request req;
4846 req.push (" SUBSCRIBE" , " channel" );
4947
50- generic_response resp;
48+ generic_flat_response resp;
5149 conn->set_receive_response (resp);
5250
5351 while (conn->will_reconnect ()) {
5452 // Subscribe to channels.
55- co_await conn->async_exec (req, ignore );
53+ co_await conn->async_exec (req);
5654
5755 // Loop reading Redis push messages.
5856 for (error_code ec;;) {
59- co_await conn->async_receive (redirect_error (use_awaitable, ec));
57+ co_await conn->async_receive2 (redirect_error (ec));
6058 if (ec)
6159 break ; // Connection lost, break so we can reconnect to channels.
62- std::cout << resp.value ().at (1 ).value << " " << resp.value ().at (2 ).value << " "
63- << resp.value ().at (3 ).value << std::endl;
60+
61+ for (auto const & elem: resp.value ().get_view ())
62+ std::cout << elem.value << " \n " ;
63+
64+ std::cout << std::endl;
65+
6466 resp.value ().clear ();
6567 }
6668 }
@@ -74,7 +76,7 @@ auto publisher(std::shared_ptr<stream_descriptor> in, std::shared_ptr<connection
7476 auto n = co_await async_read_until (*in, dynamic_buffer (msg, 1024 ), " \n " );
7577 request req;
7678 req.push (" PUBLISH" , " channel" , msg);
77- co_await conn->async_exec (req, ignore );
79+ co_await conn->async_exec (req);
7880 msg.erase (0 , n);
7981 }
8082}
0 commit comments