Channel Participants

Channel Participants

A participant object represents a user that is connected to a given channel. You can get the list of participants from the AudioChannel object. You will also get a list of participants with the onParticipantsChanged event.

Event

Description

onParticipantsChanged

When a user joins a channel you will there will be an event that gives you a list of the current channel participants. While in a given channel a similar event each time a participant enters or leaves the channel.

Example onParticipantsChanged Event Payload

{
  detail: {
    // currentParticipantId: This is the connectionId of the current user
    currentParticipantId: "871f35b5-479e-4b99-acba-71ab6fe50768",
    
    // Current Channel
    channel: AudioChannel{...},
    
    // List of participants in the channel
    participants: [Participant, Participant]      
  }
}

Rendering Participants

function handleParticipantListChange(event) {
  const participants = event.detail.participants;
  let participantList = participants.map(function (participant) {
     return '<li>' + participant.name + (participant.muted ? '' : ' (speaking)') + '</li>';
  }).join('');
  
  document.getElementById('channel-participants').innerHTML = `<ul>${participantList}</ul>`;
}

Last updated

Logo

© Copyright 2024 ALO.ai, Inc. • All Rights Reserved