문제

I'm new to the MEAN stack and trying to build a web app with it. With socket.io, I would like to randomly pair up all the users that are currently connected to the page.

My approach would be to use random integers in the range of the length of a list of all users connected, as indices of the randomly selected users in the array.

I know this is something that I can do to keep track of all clients/sockets connected:

io.sockets.on('connect', function(client) {
    clients.push(client); 

    client.on('disconnect', function() {
        clients.splice(clients.indexOf(client), 1);
    });
});

But would it have issues with scaling? If so, what would be a better approach? Please advise.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top