G
G
GizzaProger2020-08-18 17:54:39
JavaScript
GizzaProger, 2020-08-18 17:54:39

Why doesn't node.js (socket.io) save user data?

Hello.
I am using socket.io and only need to send messages to 1 user inside a large room.
I have a room connection event. In it, I write the new user to the users object.

socket.on("connect to room", data => {
        logger.info("Начал присоеденяться к комнате ", socket.id);
        users.push({
            audioOff: false,
            videoOff: false,
            id: socket.id,
            roomId: data.roomId,
            socket: socket,
            username: data.username,
            avatar: data.avatar
        });
        logger.info("Добавился в список пользователей", socket.id);
    })

Sometimes, when I connect to 1 and the same socket in different browser windows, I see that the array of users is not complete. Another user is missing. They seem to use different arrays of users.
How can I make it so that users can get a list of all users connected to a socket?
I don't quite understand where user data is stored.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question