Search code examples
javascriptapiwebrtcopentoktokbox

TokBox/OpenTok Web RTC - Limiting number of subscribers


Using the TokBox/OpenTok Javascript API - Is there any way to limit the numbers of subscribers to a stream? I.e. To only allow a single subscriber to a published stream and redirect any other subsequent would-be subscribers.


Solution

  • There isn't an explicit way to do this in the OpenTok API but I can think of a couple of ways you could do it.

    1. You could only have 1 stream per session and that way you can only give out 1 token that is allowed to connect to that session and subscribe.

    2. You could use the signaling API to send a message to the participant that is allowed to subscribe. So for example your application logic could be that a participant sends a signal to the publisher requesting that they can subscribe to the stream and if they receive a response back then they go ahead and subscribe. Then on the publisher side you can make sure you only send out one response.

    I hope you find that helpful.