Created
May 8, 2011 00:18
-
-
Save jmoyers/960987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sensitive = [ | |
{ | |
email: [email protected], | |
secret: 'somesecret', | |
username: name, | |
last_message: 'hey' | |
}, | |
{ | |
email: [email protected], | |
secret: 'somesecret2', | |
username: name1, | |
last_message: 'hey2' | |
} | |
]; | |
var filtered = _.map(sensitive, function(s){ | |
// Transform, leave out sensitive data | |
return { | |
username: s.username, | |
last_message: s.last_message | |
} | |
}); | |
// Filter sockets using underscore.js collections | |
_(sockets).select(function(socket){ | |
return socket.user.role == 'Member'; | |
}).each(function(socket){ | |
socket.send(filtered); | |
}); | |
_(sockets).select(function(socket){ | |
return socket.user.role == 'Admin'; | |
}).each(function(socket){ | |
socket.send(sensitive); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment