This message was deleted.
# helpdesk
s
This message was deleted.
✅ 1
g
2.
Copy code
setIsMuteDisabled(disabled: boolean) {
    if (disabled === this.isMuteDisabled) {
      return;
    }
    this.isMuteDisabled = disabled;
    this.emit(ParticipantEvent.IsMuteDisabledChanged, disabled);
  }
3.
Copy code
export function useIsMuteDisabled(participant?: Participant) {
  const p = useEnsureParticipant(participant);
  const observable = React.useMemo(() => createIsMuteDisabledObserver(p), [p]);
  const isMuteDisabled = useObservableState(observable, p.isMuteDisabled);

  return isMuteDisabled;
}
Copy code
export function createIsMuteDisabledObserver(participant: Participant) {
  return participantEventSelector(participant, ParticipantEvent.IsMuteDisabledChanged).pipe(
    map(([isMuteDisabled]) => isMuteDisabled),
  );
}
4.a.
const isMuteDisabled = useIsMuteDisabled(room?.localParticipant)
4.b.
Copy code
for (let remoteParticipant of room?.participants.values()){
        remoteParticipant.setIsMuteDisabled(true)
}
4.c.
Copy code
for (let remoteParticipant of room?.participants.values()){
        remoteParticipant.setIsMuteDisabled(false)
}
Note: I tried another method by creating server using Node.js Server SDK and creating API endpoints that disables/enables publishing rights for all other participants except the caller. I then used these endpoints whenever a user mute/unmute their mic. Although it did implement intended changes, I had noticeable lags in between all of the client-server, server-LiveKitServer, server-client communications and hence wanted to try a client-side implementation. If you guys have any recommendations on this method as well, I would appreciate it!
b
Hello @glamorous-nightfall-51273, I'd be curious to know if you're getting your observer events when a user mutes or unmutes. This said, another approach is simply passing data as an event, which you would then act on upon receiving. You can find useful info in this section: https://docs.livekit.io/realtime/client/data-messages/
➕ 1
a
yeah, I agree with Pat, it’ll be easier to just pass these around as data messages rather than modifying the livekit-client library
g
Thanks so much @brief-refrigerator-69901. I hadn't thought about using data messages. I just tried it and it works just as intended, and much much easier implementation too! Thanks @acoustic-engineer-41666 as well, appreciate it.
🎉 1
b
Awesome. Great news @glamorous-nightfall-51273 🔥