diff --git a/README.md b/README.md index b8b03783..6e8fb1bb 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,33 @@ redis_connector.push_command("LLEN", "my-queue", }); ``` +## Subscription with TCP-connection example +```cpp +#include "bredis/AsyncConnection.hpp" +#include +#include +... +namespace r = bredis; +namespace asio = boost::asio; +... +/* define used socket type */ +using socket_t = asio::ip::tcp::socket; +... +/* establishing connection to redis is outside of bredis */ +asio::ip::tcp::endpoint end_point( + asio::ip::address::from_string("127.0.0.1"), port); +socket_t socket(io_service, end_point.protocol()); +socket.connect(end_point); + +r::AsyncConnection subscription( + std::move(socket), + [&](const auto &error_code, r::redis_result_t &&r) { + ... + } +); +subscription.push_command("subscribe", {"some-channel1", "some-channel2"}); +``` + ## API ### `redis_result_t`