We are using Tokbox to implement a set of pre-defined chat rooms.
Each room has a moderator and a specific group of users who can join the chat room only when the moderator has activated the chat room.
This has gone very well and quite smoothly.
My question is: How could we set up say a "super user" so that they may terminate any active chat session that might be going on? This superuser is not necessarily an active participant in any room. But, we would like to set up some sort of admin page where there is a button for each room that says "emergency terminate" or something like that.
We have database roles and user setup. We are just trying to figure out the best approach to do this with the Tokbox API.
TokBox Developer Evangelist here.
A client connected to a session with a moderator token can disconnect other connected clients in that session.
There is no concept of "super user", but you can use the use the OpenTok REST API to force disconnect connected clients from any session. You can also use the OpenTok PHP SDK to accomplish this.
use OpenTok\OpenTok;
$opentok = new OpenTok($apiKey, $apiSecret);
$sessionId = ""; // the session the client is connected to
$connectionId = ""; // this connection Id of client you want to force disconnect
$opentok->forceDisconnect($sessionId, $connectionId);
As you can see, you would need to know the connectionId
of the client that you want to disconnect. The connectionId
is part of the Connection Event that is dispatched with connectionCreated
and connectionDestroyed
events on the client side. You can also use Session Monitoring to receive these connection events via a webhook on your server.