I'm building an app where the server occasionally publishes data on a given channel:
redisClient.publish('global-channel', data);
Clients need to be able to connect to the server and listen to the global broadcast. Is there anything wrong with this approach? Specifically, the creation of a redisClient for each socket connection?
io.sockets.on('connection', function(socket){
var socketRedis = redis.createClient();
socketRedis.subscribe('global-channel');
socketRedis.on('message', function(ch, msg){
socket.emit('event', msg);
});
});
I'm new to Node, Redis, AND socket.io ... still learning which piece should handle certain tasks and where (server vs. client side) -- thanks!