From 0625e7c5fe9cb99d5c6eca6961dac8da00566a36 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Mon, 27 Jun 2011 23:55:25 +0200 Subject: [PATCH] Update examples --- example-ae.c | 13 ++++++++----- example-libev.c | 12 ++++++++---- example-libevent.c | 12 ++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/example-ae.c b/example-ae.c index 28c34dc..5ed34a3 100644 --- a/example-ae.c +++ b/example-ae.c @@ -18,17 +18,20 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { redisAsyncDisconnect(c); } -void connectCallback(const redisAsyncContext *c) { - ((void)c); - printf("connected...\n"); +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"); - aeStop(loop); + printf("Disconnected...\n"); } int main (int argc, char **argv) { diff --git a/example-libev.c b/example-libev.c index 8efa1e3..7894f1f 100644 --- a/example-libev.c +++ b/example-libev.c @@ -15,16 +15,20 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { redisAsyncDisconnect(c); } -void connectCallback(const redisAsyncContext *c) { - ((void)c); - printf("connected...\n"); +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"); + printf("Disconnected...\n"); } int main (int argc, char **argv) { diff --git a/example-libevent.c b/example-libevent.c index f6f8c83..9da8e02 100644 --- a/example-libevent.c +++ b/example-libevent.c @@ -15,16 +15,20 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { redisAsyncDisconnect(c); } -void connectCallback(const redisAsyncContext *c) { - ((void)c); - printf("connected...\n"); +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"); + printf("Disconnected...\n"); } int main (int argc, char **argv) {