Skip to content

Instantly share code, notes, and snippets.

@guiltry
Last active August 29, 2015 14:15
Show Gist options
  • Save guiltry/bafad017fc34ca4b8c30 to your computer and use it in GitHub Desktop.
Save guiltry/bafad017fc34ca4b8c30 to your computer and use it in GitHub Desktop.
socket.on('subscribe_public', function (m) {
socket.join(m.channel);
});
socket.on('subscribe_private', function (m) {
if (m.jwt && is_valid_jwt(m.jwt)) {
socket.join(m.channel);
}
});
// On redis publish event.
redis.sub.on('message', function(channel, message) {
msg = JSON.parse(message);
io_broadcast.in(msg.channel).emit(msg.event, msg.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment