Skip to content

Instantly share code, notes, and snippets.

@tanqhnguyen
Created September 8, 2012 09:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanqhnguyen/3672976 to your computer and use it in GitHub Desktop.
Save tanqhnguyen/3672976 to your computer and use it in GitHub Desktop.
var client = bayeux.getClient()
, channelKeyPrefix = "room:";
bayeux.bind('subscribe', function(clientId, channel){
redisClient.incr(channelKeyPrefix + channel, function(error, value){
client.publish(channel, {
event: 'user-change',
params: {
onlineUsers: value
}
});
});
});
bayeux.bind('unsubscribe', function(clientId, channel){
redisClient.decr(channelKeyPrefix + channel, function(error, value){
client.publish(channel, {
event: 'user-change',
params: {
onlineUsers: value
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment