Code Monkey home page Code Monkey logo

Comments (9)

leslie-alldridge avatar leslie-alldridge commented on July 19, 2024 1

In @Ayush909's code you can see a surrounding if conditional that you are missing @Somsubhra1 https://github.com/Somsubhra1/ChatSpace/blob/master/server.js#L72-L82

If that doesn't help, I suggest console logging or using debug to find what properties exist in the user object to ensure that it's not appearing as null or without a room.

from chatcord.

upendradhamala avatar upendradhamala commented on July 19, 2024 1

@Ayush909 How did you get the solution later? I am facing the exact same issue?

from chatcord.

egin10 avatar egin10 commented on July 19, 2024 1

Hi there, this is my code https://github.com/egin10/anonymous-chat
It's work properly.
Hope it can help you guys.

from chatcord.

Ayush909 avatar Ayush909 commented on July 19, 2024

https://github.com/Ayush909/dechat1.0
here is my repo
Please help

from chatcord.

Somsubhra1 avatar Somsubhra1 commented on July 19, 2024

Should be io.to(user.room) instead of io.in(user.room).
Check my repo at https://github.com/Somsubhra1/ChatSpace.

from chatcord.

Ayush909 avatar Ayush909 commented on July 19, 2024

Should be io.to(user.room) instead of io.in(user.room).
Check my repo at https://github.com/Somsubhra1/ChatSpace.

Still getting the same error.

from chatcord.

DanielGannage avatar DanielGannage commented on July 19, 2024

Was this issue ever solved? I have the exact same issue. I have a feeling the users[] array is not persisting, because whenever I print out the array using .map, I get: id: undefined, username: undefined, room: undefined multiple times. I am going to try to save the array to a file for persistence and see if this works.

from chatcord.

leslie-alldridge avatar leslie-alldridge commented on July 19, 2024

There was never a problem in the first place.. I followed the tutorial and it worked fine. Feel free to link your repo

from chatcord.

DanielGannage avatar DanielGannage commented on July 19, 2024

Found the issue, on the client side I was instantiating multiple io() objects. This was opening multiple connections per browser session. The multiple connections created multiple socket.ids which did not work well with return users.find(user => user.id === id); - basically returning undefined

from chatcord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.