I’m building a chat app and i’m comfused at some point how should be socket io logic these are my things plese share if there is a more optimal option
1-) The new message events are emit for all user kinda like that
users.forEach((user) => {
if (user._id == newMessageRecieve.sender._id) return;
socket.in(user._id).emit('message recieved', newMessageRecieve);
});
2-) The other option is emiting to chatId but in this case i need add user to all existing chat.
I mean if user has 50 Conversation user should be in 50 different room
this is the situation i’m open the all advice.