Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:24:54+00:00 2026-06-14T22:24:54+00:00

I am using socket.io to make a chat application where I need to show

  • 0

I am using socket.io to make a chat application where I need to show the current user list.
Till now it is working fine with the current user list being displayed

I am using this code for maintaining the user list

usernames[socket.id] = name;//where name is the name of the user

Then on disconnect I am again deleting that user from the list

delete usernames[socket.id];

But, my problem with this method is that suppose there are three users a,b and c

now the userlist will be populated on the connection event,something like this

 io.sockets.on('connection', function(socket) { 

    ...

    socket.on('register', function(name) {

    usernames[socket.id] = name;

And the user list will be something like “a,b and c”

But, what I want is that for user “a” the list should show “b and c” and for “b” it should be “a and c” and for “c” it should be “a and b”.

I also thought about removing it on the client side based on some variable which stores the name of the user who is viewing it but for this chat multiple users can have the same name.
So if suppose all the three have name “a” then it will remove all three instead of removing only one name from the list.

….I guess I am out of ideas on this one. Plz help me to implement it in socket.io

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:24:55+00:00Added an answer on June 14, 2026 at 10:24 pm

    Your question has nothing to do with Socket.IO really. When displaying a list of users, simply don’t display the current user!

    for (userIndex in users) {
        if (users[userIndex].id !== currentUser.id) {
            // Add user to displayed user list
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have try to make chat application with socket programing and I am using
Does anybody know how to make socket chat in C++ using something like sockets
I trying to make a small chat website using node.js and socket.io. To include
So. I have got web-chat working on socket.io. I'm thinking of using it also
I'm working on a chat application using C and unix low level sockets. I
I have a application in which I am using socket programming , having this(image)
I want to create a test program about using socket. First i need to
I'm building an application in which I am using Socket Programming in Java using
i`m new in node js. I make chat for browser game using node js
Have been struggling all day trying to make this simple example work using socket.io.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.