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-ae.c | |
parent | 822efe2ac3174685ec26d3e01e223fe25ed77aa2 (diff) |
Fire onConnect callback on the first write event
Diffstat (limited to 'example-ae.c')
-rw-r--r-- | example-ae.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/example-ae.c b/example-ae.c index fc471fb..28c34dc 100644 --- a/example-ae.c +++ b/example-ae.c @@ -18,10 +18,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"); aeStop(loop); } @@ -37,6 +43,7 @@ int main (int argc, char **argv) { loop = aeCreateEventLoop(); redisAeAttach(loop, c); + 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"); |