// Global variables for maintaining game states
// TODO: Clear this when a new game is started
var nrecieved = 0;
var responses = {}; // Socket id to response
function finish(/* todo: maybe also pass in a game_id or one of the user ids to know which game is being played */){
// Loop through users in game and send them their responses
for(var id in responses){
if(responses.hasOwnProperty(id)){
// Send the response
io.to(id).emit('updatePlayer', responses[id]);
}
}
}
socket.on('playerCorrect', function (data) {
responses[socket.id] = data;
nrecieved++;
if(nrecieved == 2){
finish();
dataRequest();
}
});
socket.on('playerWrong', function (data) {
responses[socket.id] = data;
nrecieved++;
// Only respond if both responses received
if(nrecieved == 2){
finish();
dataRequest();
}
});

socket.id is a unique identifier assigned to each socket which may be useful. For multi-game performance, you will probably need to have more logic to maintain a list of which sockets/players belong to which games and then use that to direct messages to the correct pairs of users.

Email codedump link for Socket.io event that waits for both players to have chosen answers