From 8c0a43195ee52c1e7f1c73a94fffdcd998812dd2 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 25 Nov 2016 11:56:56 -0500 Subject: [PATCH] Add support for custom data when returning a list of all socket clients --- README.md | 6 ++++++ index.js | 53 +++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 42f10a2..e6e1c01 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ that a regular `Adapter` does not Returns the list of client IDs connected to `rooms` across all nodes. See [Namespace#clients(fn:Function)](https://github.com/socketio/socket.io#namespaceclientsfnfunction) +### RedisAdapter#setCustomClientHook(fn:Function) + +Sets a custom hook on the RedisAdapter#clients call, so that its callback +provides custom data related to a client in addition to the array of client IDs. +The input function takes a single argument, clientID. + ## Client error handling Access the `pubClient` and `subClient` properties of the diff --git a/index.js b/index.js index 04df130..7c5d93b 100644 --- a/index.js +++ b/index.js @@ -165,10 +165,20 @@ function adapter(uri, opts){ return; } + // construct client custom data from the custom hook + var clientsData = []; + for(var i=0; i