Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs edits for Force Mute API additions #2

Open
wants to merge 1 commit into
base: mute-all
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,33 +420,37 @@ opentok.forceDisconnect(sessionId, connectionId, function (error) {
This is the server-side equivalent to the forceDisconnect() method in OpenTok.js:
<https://www.tokbox.com/developer/guides/moderation/js/#force_disconnect>.

### Force Mute a participant
### Forcing a publisher to mute audio

You can force mute participants from an OpenTok Session using the
`openTok.forceMute(sessionId, streamId, callback)` method.
You can force the publisher of a specified stream to mute its audio using the
`OpenTok.forceMute(sessionId, streamId, callback)` method.

```javascript
opentok.forceMute(sessionId, streamId, function (error) {
if (error) return console.log("error:", error);
});
```

### Force Mute All participants
### Forcing all participants in a session to mute audio

You can force mute all participants from an OpenTok Session using the
You can force all publishers in the session (except for those publishing
excluded streams) to mute audio using the
`openTok.forceMuteAll(sessionId, excludedStreamIds, callback)` method.
To mute all participants call forceMuteAll with out excludedStreamIds.
To exclude streams from being muted use the excludedStreamIds.

To mute audio in all streams in the session, call the method without adding an
`excludedStreamIds` parameter:

```javascript
const excludedStreamIds = ['stream1','stream2'];
opentok.forceMuteAll(sessionId, excludedStreamIds, function (error) {
opentok.forceMuteAll(sessionId, null, function (error) {
if (error) return console.log("error:", error);
});
```

To exclude streams from being muted, use the `excludedStreamIds` parameter:

```javascript
opentok.forceMuteAll(sessionId, null, function (error) {
const excludedStreamIds = ['stream1','stream2'];
opentok.forceMuteAll(sessionId, excludedStreamIds, function (error) {
if (error) return console.log("error:", error);
});
```
Expand Down
4 changes: 2 additions & 2 deletions lib/muteModeration.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ var api = function (config, method, session, stream, body, callback) {

handleForceMute = function (config, sessionId, streamId, excludedStreamIds = null, callback) {
if (typeof callback !== 'function') {
throw (new errors.ArgumentError('No callback given to signal'));
throw (new errors.ArgumentError('No callback given'));
}
if (sessionId == null) {
return callback(new errors.ArgumentError('No sessionId or connectionId given to signal'));
return callback(new errors.ArgumentError('No sessionId or streamId given'));
}
let body=null;
if(excludedStreamIds){
Expand Down
10 changes: 5 additions & 5 deletions lib/opentok.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ OpenTok = function (apiKey, apiSecret, env) {
this.forceDisconnect = moderation.forceDisconnect.bind(null, apiConfig);

/**
* Mutes a participant from an OpenTok session.
* Forces the publisher of a specified stream to mute its audio.
*
* @param sessionId The session ID for the OpenTok session that the client you want
* to mute is connected to.
Expand All @@ -824,12 +824,12 @@ OpenTok = function (apiKey, apiSecret, env) {
this.forceMute = muteModeration.forceMute.bind(null, apiConfig);

/**
* Mutes a participant from an OpenTok session.
* Forces all publishers in the session (except for those publishing excluded streams)
* to mute audio.
*
* @param sessionId The session ID for the OpenTok session that the client you want
* to mute is connected to.
* @param sessionId The session ID for the OpenTok session in which you want to mute clients.
*
* @param excludedSteamIds (optional) A list of stream Ids to exclude from mute.
* @param excludedSteamIds (optional) A list of stream IDs to exclude from being muted.
*
* @param callback {Function} The function to call upon completing the operation. Two arguments
* are passed to the function:
Expand Down