onUserAudioStateChanged method

void onUserAudioStateChanged(
  1. String userId,
  2. bool hasAudio,
  3. TUIChangeReason reason
)

Implementation

void onUserAudioStateChanged(String userId, bool hasAudio, TUIChangeReason reason) {
  if (hasAudio) {
    userState.hasAudioStreamUserList.value.add(userId);
  } else {
    userState.hasAudioStreamUserList.value.remove(userId);
  }
  final LinkedHashSet<String> tempList = LinkedHashSet<String>();
  tempList.addAll(userState.hasAudioStreamUserList.value);
  userState.hasAudioStreamUserList.value = tempList;
  if (userId == userState.selfInfo.userId) {
    mediaState.isMicrophoneMuted.value = !hasAudio;
    if (hasAudio) {
      mediaState.isMicrophoneOpened.value = true;
    }
  }
}