跳轉到

RemoteParticipant

A RemoteParticipant is a friend who is in the call with you. Get one from Room.remoteParticipants on Room.shared, keyed by friend ID.

Ask to mute or unmute

To have a participant turn their sound off or back on, call requestMute(_:) on them. It asks them to mute or unmute: pass true to ask them to mute, false to ask them to unmute. It is a request, not a command. The participant receives it as didReceiveMuteRequest (see Events), and their app decides whether to do it, for example by showing a prompt or by turning off their microphone. Nothing changes on their side until their app acts.

requestMute(_:) returns true once their device has received the request. It throws when the request cannot be delivered: RoomMessageError.transportFailed(underlying:) wraps the reason, such as FriendMessageError.friendNotReachable or FriendMessageError.timeout(messageId:) when their device does not confirm within 10 seconds. Both of these can be retried later.

import RevueSDK

/// Ask a participant to mute (or unmute, with muted: false). Returns false when the request could
/// not be delivered, for example because they are unreachable right now; try again later.
/// Whether they actually mute is decided by their app, which receives didReceiveMuteRequest.
func askToMute(friendId: String, muted: Bool) async -> Bool {
    guard let participant = Room.shared.remoteParticipants[friendId] else { return false }
    do {
        return try await participant.requestMute(muted)
    } catch {
        return false
    }
}