Closed CurtTilmes closed 7 years ago
I added this little sub and it seems to work for pub/sub, but I'm not sure I'm doing everything right..
/**
* @brief eredis reader reply, blocking for pub/sub
*
* @param r eredis reader
*
* @return reply (redisReply)
*/
eredis_reply_t *
eredis_r_reply_blocking( eredis_reader_t *r )
{
redisContext *c;
eredis_reply_t *reply;
int err;
reply = NULL;
if (!(c = _eredis_r_ctx(r, 0)))
return NULL;
err = redisGetReply( c, (void**)&reply );
if (err == EREDIS_OK) {
/* Good */
/* Previous to clean? */
_eredis_r_free_reply( r );
/* New reply */
r->reply = reply;
} else {
/* Bad */
if (reply)
freeReplyObject( reply );
err = c->err;
}
return reply;
}
Moved to pull request #8
What is the right way to implement publish/subscribe on top of eredis?
I tried sending a 'subscribe' command, and it works fine, but I can't call eredis_r_reply() in a blocking manner to wait for a response that hasn't come yet.