From aa4d69606d585fbff7e721a6c48db3d156cd12d1 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 22 Oct 2019 16:50:52 +0200 Subject: [PATCH] Modules hooks: do more in example client callback. --- src/modules/hellohook.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/hellohook.c b/src/modules/hellohook.c index ec3c9d264..ea0ac517d 100644 --- a/src/modules/hellohook.c +++ b/src/modules/hellohook.c @@ -41,8 +41,13 @@ void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) { REDISMODULE_NOT_USED(ctx); + REDISMODULE_NOT_USED(e); + 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