X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/2612e0521fde55db2c720092d4ad02a8f015f46e..e5f794ff3abd844a08c0b01faa15550fd7014d7c:/deps/hiredis/example-libevent.c diff --git a/deps/hiredis/example-libevent.c b/deps/hiredis/example-libevent.c index c257bb6c..9da8e02b 100644 --- a/deps/hiredis/example-libevent.c +++ b/deps/hiredis/example-libevent.c @@ -15,10 +15,20 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { redisAsyncDisconnect(c); } +void connectCallback(const redisAsyncContext *c, int status) { + if (status != REDIS_OK) { + printf("Error: %s\n", c->errstr); + return; + } + printf("Connected...\n"); +} + void disconnectCallback(const redisAsyncContext *c, int status) { if (status != REDIS_OK) { printf("Error: %s\n", c->errstr); + return; } + printf("Disconnected...\n"); } int main (int argc, char **argv) { @@ -33,6 +43,7 @@ int main (int argc, char **argv) { } redisLibeventAttach(c,base); + redisAsyncSetConnectCallback(c,connectCallback); redisAsyncSetDisconnectCallback(c,disconnectCallback); redisAsyncCommand(c, NULL, NULL, "SET key %b", argv[argc-1], strlen(argv[argc-1])); redisAsyncCommand(c, getCallback, (char*)"end-1", "GET key");