R
R
RomanSS2016-12-27 12:31:08
JavaScript
RomanSS, 2016-12-27 12:31:08

What is better to use in socket.io when using multiple tabs?

Tell me, what is better to use when the user has many tabs open? rooms or user card?
Under the user map, I'm talking about code like this: (read more here stackoverflow )

var socketMap = {};
if(!socketMap[userId]) socketMap[userId] = [];
socketMap[userId].push(socket);

I doubted the use of standard rooms in socket.io, since sending to rooms occurs when all users are bypassed and checking which rooms they are in. Those. with 1000 connected clients, in order to send a message to a specific user, it turns out that there will be a traversal of all 1000 connected sockets. Perhaps I misunderstood how the rooms are arranged.
And if you use a user map, you can bypass only the array of sockets that is in the map.
What can you say about this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
catHD, 2016-12-27
@RomanSS

You misunderstood. The room is the same set of socketIds as your "socketMap".
Implement as you see fit, hash/array/rooms.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question