Moderation

Wenn Sie mit einer Sitzung verbinden mit einem Token, das Moderatorenrechte beinhaltet, können Sie andere Clients zwingen, die Verbindung zu einer Sitzung zu trennen oder ihren Ton stumm zu schalten:

Überprüfung der Moderationsberechtigung

Sobald Sie eine Verbindung zu einer Sitzung hergestellt haben, können Sie prüfen, ob der Client moderieren kann.

Check the value of the capabilities.forceMute property of the OTSession object. If it is set to true, the client can moderate:

if (session.capabilities.forceMute) {
    // The client can mute participants.
} else {
    // The client cannot mute.
}

Stummschalten des Audios von Streams in einer Sitzung

Moderatoren können alle Clients oder einen Publisher eines bestimmten Streams dazu zwingen, ihre veröffentlichten Audiodaten stumm zu schalten.

To force a publisher of a specific stream to mute its audio, call the forceMuteStream() method of the Session object, passing in the Stream object representing the stream you want to mute:

session.forceMuteStream(stream)
    .catch(function() {
    console.log("successfully called.");
    }).catch(function(error) {
    console.log("Error: ", error);
});

The Session.forceMuteStream() method returns a Promise that is rejected if the call fails. For example, if the client does not have moderation privileges, the Promise is rejected with the name property of the Error object set to "OT_PERMISSION_DENIED". In this context, success indicates that the options passed into the method are valid and the request to mute the stream was sent. It does not guarantee that the request was successfully acted upon.

Moderators can also force all streams (except for an optional array of streams) in a session to mute published audio. Call the forceMuteAll() method of the Session object, passing an array of streams that you want to exclude from muting:

session.forceMuteAll(excludedStreams);

A stream published by the moderator calling the forceMuteAll() method is muted along with other streams in the session, unless you add the moderator's stream (or streams) to the excluded streams array.

If you leave out the excludedStreams parameter, all streams in the session (including those of the moderator) will stop publishing audio:

session.forceMuteAll();

Also, any streams that are published after the call to the forceMuteAll() method are published with audio muted. You can remove the mute state of a session by calling the disableForceMute() method of the Session object:

session.disableForceMute();

After you call the Session.disableForceMute() method, new streams published to the session will no longer have audio muted.

You can get references to Stream objects when the Session object dispatches a sessionConnected event and a streamCreated event. See Getting available streams when connecting to a session.

You can also get a Stream object from the stream property of a Subscriber object.

When the stream is muted as a result of one of these methods (or from a force mute stream call in another client SDK, in each client publishing a muted stream, the Publisher object dispatches a muteForced event.

Similarly, in response to a call to the Session.forceMuteAll() method (or to a force mute all call in another client SDK, the Session object in each client connected to the session dispatches a muteForced event, and the active property of the event object is set to true.

And in response to a call to the Session.disableForceMute() method (or to a disable force mute call in another client SDK, the Session object in each client connected to the session dispatches a muteForced event, and the active property of the event object is set to false.

Erzwingen der Verbindungstrennung eines Clients

Moderatoren können jeden Kunden zwingen, die Verbindung zur Sitzung zu beenden.

To force a client to disconnect, call the forceDisconnect() method of the Session object, passing in the Connection object for the client you want to disconnect:

session.forceDisconnect(connection);

You can get references to Connection objects when the Session object dispatches a connectionCreated event. See Detecting when other clients have connected and disconnected. You can also get the Connection object for any stream from the connection property of the Stream object.

Zwingen eines Clients, die Veröffentlichung eines Streams zu beenden

Moderatoren können jeden Herausgeber eines Streams dazu zwingen, das Streaming für die Sitzung zu beenden.

To force a stream to stop, call the forceUnpublish() method of the Session object, passing in the Stream object that you want to stop:

session.forceUnpublish(stream);

You can get references to Stream objects when the Session object dispatches a sessionConnected event and a streamCreated event. See Getting available streams when connecting to a session.

You can also get a Stream object from the stream property of a Subscriber object.