opentoktokboxvonage

How can a client with moderator token can only unpublish video?


I have usecases where a moderator can stop video of a client but not audio, and a case where only audio to be disable but not the video.

I have seen moderator documentation, but it seems it will disable the both audio/video for the client.


Solution

  • The moderator token let's you disconnect other clients, not mute them.

    If you want to mute other clients or perform any other actions, you can leverage the Opentok Signal feature (https://tokbox.com/developer/guides/signaling/js/), and send a signal to all clients that you want to mute.

    For example:

    // Moderator side
    
    session.signal(
      {
        data:"muteAll"
      },
      function(error) {
        if (error) {
          console.log("signal error ("
                       + error.name
                       + "): " + error.message);
        } else {
          console.log("signal sent.");
        }
      }
    );
    
    // Client Side
    
    session.on("signal", function(event) {
          console.log("Signal sent from connection " + event.from.id);
          // Process the event.data property, if there is any data.
         if (event.data === "muteAll"){
           publisher.publishAudio(false);
           publisher.publishVideo(false);
         }
        });
    

    I hope it helps