if (isAllParticipants) {
presentParticipantsTracker = JsonCollections.createStringSet();
}
for (int i = 0; i < result.size(); i++) {
ParticipantUserDetails item = result.get(i);
UserDetails userDetails = item.getUserDetails();
String userId = userDetails.getUserId();
// Cache the participants' user details.
participantUserDetails.put(userId, userDetails);
clientIdToUserId.put(item.getParticipant().getId(), userId);
if (isAllParticipants) {
presentParticipantsTracker.add(userId);
if (!participantsByUserId.containsKey(userId)) {
createAndAddParticipant(item.getParticipant(), userDetails);
}
} else {
/*
* Add the participant to the list. If the user is not in presentParticipantsTracker set,
* then the participant has since disconnected. If the user is in the participants map, then
* the user was already added to the view.
*/
if (presentParticipantsTracker.contains(userId)
&& !participantsByUserId.containsKey(userId)) {
createAndAddParticipant(item.getParticipant(), userDetails);
}
}
}
// Sweep through participants to find removed participants.