Socket IO Rooms: Get list of clients in specific room

I’m trying to display a list of clients in a specific room. I just want to show their username, and not their socket id.

This where I’m at:

socket.set('nickname', "Earl");  
socket.join('chatroom1');
console.log('User joined chat room 1);

var roster = io.sockets.clients('chatroom1');
for ( i in roster )
{
   console.log('Username: ' + roster[i]);   
}

Haven’t had any luck getting it to list Socket IDs or anything. Would like it to return the nicknames however.

122 thoughts on “Socket IO Rooms: Get list of clients in specific room”

  1. Undeniably believe that which you stated. Your favorite reason seemed to be on the internet the simplest thing to
    be aware of. I say to you, I definitely get annoyed while people
    think about worries that they plainly do not know about.
    You managed to hit the nail upon the top as well as defined out the whole thing without
    having side effect , people can take a signal. Will likely be back
    to get more. Thanks

    Reply
  2. That is really attention-grabbing, You’re an overly professional blogger.
    I have joined your feed and sit up for looking for more of your excellent
    post. Additionally, I’ve shared your website in my social
    networks

    Reply
  3. Does your site have a contact page? I’m having problems locating it but,
    I’d like to shoot you an e-mail. I’ve got some suggestions for your blog
    you might be interested in hearing. Either way, great blog and I look forward to seeing it expand
    over time.

    Reply
  4. Great items from you, man. I’ve keep in mind your stuff previous to
    and you’re simply extremely excellent. I really like what you
    have received here, really like what you are saying and the way by
    which you assert it. You make it entertaining and you continue to take care of to
    keep it sensible. I can not wait to learn far more from you.
    That is really a tremendous website.

    Reply
  5. Does your blog have a contact page? I’m having trouble locating it but,
    I’d like to shoot you an e-mail. I’ve got some recommendations for your blog you might be interested in hearing.
    Either way, great website and I look forward to seeing it develop over time.

    Reply
  6. Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your weblog?
    My blog is in the exact same area of interest as yours and my users would definitely benefit from
    a lot of the information you present here. Please let me
    know if this okay with you. Thanks!

    Reply
  7. Wonderful beat ! I would like to apprentice while you amend
    your web site, how can i subscribe for a blog site?
    The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear
    concept

    Reply
  8. I think that what you wrote was actually very logical.
    However, what about this? suppose you added a little content?
    I am not suggesting your content isn’t solid, however what if you added a title to maybe
    get folk’s attention? I mean Socket IO Rooms: Get list of clients
    in specific room – JavaScript Help is a little boring.
    You should look at Yahoo’s home page and see how they create post headlines to grab
    viewers interested. You might add a video or a related picture or two
    to get readers excited about what you’ve got to say. Just my opinion, it would bring your posts a little bit more
    interesting.

    Reply
  9. Greetings, I think your website could possibly be having internet
    browser compatibility issues. When I look at your
    blog in Safari, it looks fine but when opening in Internet Explorer, it’s got some
    overlapping issues. I merely wanted to give you a quick heads
    up! Aside from that, wonderful blog!

    Reply