diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-12-07 10:22:30 +0100 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-12-07 10:22:30 +0100 |
commit | 12725f88ed2f77ee7a003458906c34dc20511e0e (patch) | |
tree | 8217f41642a5aeea148846a534328d409725cc60 /example-libevent.c | |
parent | 822efe2ac3174685ec26d3e01e223fe25ed77aa2 (diff) |
Fire onConnect callback on the first write event
Diffstat (limited to 'example-libevent.c')
-rw-r--r-- | example-libevent.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/example-libevent.c b/example-libevent.c index c257bb6..f6f8c83 100644 --- a/example-libevent.c +++ b/example-libevent.c @@ -15,10 +15,16 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { redisAsyncDisconnect(c); } +void connectCallback(const redisAsyncContext *c) { + ((void)c); + printf("connected...\n"); +} + void disconnectCallback(const redisAsyncContext *c, int status) { if (status != REDIS_OK) { printf("Error: %s\n", c->errstr); } + printf("disconnected...\n"); } int main (int argc, char **argv) { @@ -33,6 +39,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"); |