2
0
mirror of https://github.com/boostorg/redis.git synced 2026-02-21 15:22:14 +00:00

More refactoring.

This commit is contained in:
Marcelo Zimbres
2021-10-30 20:55:19 +02:00
parent 60c0d7dac7
commit 187c1e6a0e
15 changed files with 142 additions and 159 deletions

View File

@@ -21,14 +21,14 @@ net::awaitable<void> publisher()
std::queue<resp3::request> requests;
requests.push({});
requests.back().push(command::hello, "3");
requests.back().push(command::hello, 3);
resp3::connection conn;
resp3::stream s;
for (;;) {
resp3::response resp;
co_await conn.async_consume(socket, requests, resp);
co_await s.async_consume(socket, requests, resp);
if (requests.front().elements.front().cmd == command::hello) {
if (requests.front().commands.front() == command::hello) {
prepare_next(requests);
requests.back().push(command::publish, "channel1", "Message to channel1");
requests.back().push(command::publish, "channel2", "Message to channel2");
@@ -48,20 +48,20 @@ net::awaitable<void> subscriber()
requests.push({});
requests.back().push(command::hello, "3");
resp3::connection conn;
resp3::stream s;
for (;;) {
resp3::response resp;
co_await conn.async_consume(socket, requests, resp);
co_await s.async_consume(socket, requests, resp);
if (resp.get_type() == resp3::type::push) {
std::cout << "Subscriber " << id << ":\n" << resp << std::endl;
continue;
}
if (requests.front().elements.front().cmd == command::hello) {
if (requests.front().commands.front() == command::hello) {
id = resp.raw().at(8).data;
prepare_next(requests);
requests.back().subscribe({"channel1", "channel2"});
requests.back().push(command::subscribe, "channel1", "channel2");
}
}
}