How can I end a session for all participants?

Objective

Ending a session for all participants.

Applies To

  • Video API

Procedure

An Opentok session cannot be destroyed, but it is possible to disconnect clients from it and prevent them from rejoining.

A Publisher with a token that has a “Moderator” role assigned can force any user to disconnect from a session.

To do so, the Moderator calls the forceDisconnect() method of the Session object, passing in the Connection object for the client you want to disconnect:

session.forceDisconnect(connection);

In order to prevent rejoining a session, you can generate a token that has a short lifespan. Once the client that got disconnected from a session (and has an expired token) cannot rejoin the session.

Additional Information

Note, that even when a token is expired, a client will stay connected to a session until gets disconnected (either by calling forceDisconnect() or on its own).

Have more questions? Submit a request