in demo-website/src/meeting.js [492:555]
setupSubscribeToAttendeeIdPresenceHandler() {
const handler = (attendeeId, present, externalUserId) => {
this.log(`attendeeId:${attendeeId} | externalUserId:${externalUserId} | present = ${present}`);
//add externalUserId to roster
if (!this.roster[attendeeId]) {
this.roster[attendeeId] = { externalUserId: externalUserId };
}
if (!present) {
delete this.roster[attendeeId];
this.updateRoster();
return;
}
this.audioVideo.realtimeSubscribeToVolumeIndicator(
attendeeId,
async (attendeeId, volume, muted, signalStrength) => {
if (volume !== null) {
this.roster[attendeeId].volume = Math.round(volume * 100);
}
if (muted !== null) {
this.roster[attendeeId].muted = muted;
}
if (signalStrength !== null) {
this.roster[attendeeId].signalStrength = Math.round(signalStrength * 100);
}
if (!this.roster[attendeeId].name) {
this.roster[attendeeId].name = 'Loading'
const response = await fetch(`${DemoMeetingApp.MeetingAPI}attendee-name?externalMeetingId=${encodeURIComponent(this.externalMeetingId)}&attendeeExternalUserId=${encodeURIComponent(this.roster[attendeeId].externalUserId)}`);
const jsonResponse = await response.json();
this.roster[attendeeId].name = jsonResponse.data ? jsonResponse.data : '';
}
this.updateRoster();
}
);
};
this.audioVideo.realtimeSubscribeToAttendeeIdPresence(handler);
const activeSpeakerHandler = (attendeeIds) => {
for (const attendeeId in this.roster) {
this.roster[attendeeId].active = false;
}
for (const attendeeId of attendeeIds) {
this.roster[attendeeId].active = true;
break; // only show the most active speaker
}
this.layoutVideoTiles();
};
this.audioVideo.subscribeToActiveSpeakerDetector(
new DefaultActiveSpeakerPolicy(),
activeSpeakerHandler,
(scores) => {
for (const attendeeId in scores) {
if (this.roster[attendeeId]) {
this.roster[attendeeId].score = scores[attendeeId];
}
}
this.updateRoster();
},
this.showActiveSpeakerScores ? 100 : 0,
);
}