글
distinctive syntax of javascript
JS
2014. 6. 19. 19:10
You can create an array object of user collection as
var users = {};
then on server side you can add it as new user when you connect
socket.on('new-user', function (username) {
users[username] = username;
});
while displaying the users, you can loop the "users" object
On Client side
var socket = io.connect();
socket.on('connect', function () {
socket.emit('new-user', 'username');
});
http://stackoverflow.com/questions/18093638/socket-io-rooms-get-list-of-clients-in-specific-room