Modules hooks: do more in example client callback.

This commit is contained in:
antirez 2019-10-22 16:50:52 +02:00
parent cf52e0ad44
commit c379fdbae2

View File

@ -41,8 +41,13 @@
void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data)
{ {
REDISMODULE_NOT_USED(ctx); REDISMODULE_NOT_USED(ctx);
REDISMODULE_NOT_USED(e);
RedisModuleClientInfo *ci = data; RedisModuleClientInfo *ci = data;
printf("Client event for client #%llu %s:%d\n",ci->id,ci->addr,ci->port); printf("Client %s event for client #%llu %s:%d\n",
(sub == REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ?
"connection" : "disconnection",
ci->id,ci->addr,ci->port);
} }
/* This function must be present on each Redis module. It is used in order to /* This function must be present on each Redis module. It is used in order to