質問

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