Re: How to use Pub/sub with hiredis in C++?

1,790 views
Skip to first unread message

Aleksandar Radulovic

unread,
Jul 25, 2012, 3:39:14 PM7/25/12
to redi...@googlegroups.com
Hi,

When you issue a redis command to subscribe to a channel, you are
supposed to pass a callback to be called whenever there's a message
sent to that channel. There are examples for redisAsyncCommand in
hiredis sources, afaik.

-alex

On Wed, Jul 25, 2012 at 8:21 AM, Jae Park <bkb...@gmail.com> wrote:
> I am trying to test this pub/sub function of redis with hiredis client via
> c++.
>
> I can see that subscribing to certain channel seems to be easy enough to do
> through redisCommand Api.
>
> However I am wondering how the reply is coming back when somebody publish to
> the certain server.
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/redis-db/-/CQdKcO2th3EJ.
>
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.



--
a lex 13 x
http://a13x.net | @a13xnet

Salvatore Sanfilippo

unread,
Jul 25, 2012, 4:04:49 PM7/25/12
to redi...@googlegroups.com
p.s. warning, hiredis has a bug so that if you send the SUBSCRIBE
command while the server is loading the DB, or before AUTH, or in any
other setup where Redis will reply with an error in the form of
"-"+<something>, hiredis will crash.

I already submitted a bug report but it's better to be aware of that
to use Pub/Sub with hiredis.

Cheers,
Salvatore
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org

Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
— David Gelernter

Jae Park

unread,
Jul 25, 2012, 8:37:28 PM7/25/12
to redi...@googlegroups.com

if I use a redisAsyncContext for subscribing,

is that Context unable to be used in other ways ?
 
 
Reply all
Reply to author
Forward
0 new messages