I'm building a chat app that's similar to Facebook Messenger. It should have 2 screens, one display a list of conversations that the user is a part of as well as its last message, and the other is the chat screen of a particular conversation. I searched a bit and found out that on the server side we could allow the client to join multiple rooms at once.
Is this common to join client to multiple rooms upon connection? For example when connection is established I'd query the database to find all conversations of the user, and let him join all of that rooms (each room map to a conversation). This way when the user stays in the conversation list, he can still receive messages coming from any conversations.
Something like this:
io.on("connection", (socket) => {
const userRooms = await db.findUserRooms(socket.userId);
socket.join(userRooms);
});
Does this have any performance impact when for example each users have hundreds of conversations?