Search code examples
webrtcopentoktokbox

OpenTok/TokBox: is there a way to limit the number of published streams allowed in a session?


I'm using OpenTok Web Client SDK and OpenTok .NET Server SDK to generate TokBox sessions that are always going to be multiparty conferences with video being published by many.

I'd like to limit the number of streams that can be published and somehow set that as a session property. Right now I know this value - the number of current publishers - in the client side, and I can of course prevent a new user to publish, but I'm running into this scenario where two users try to publish at the same time, and both are accepted. Ideally the user who published the very first of the two should be accepted, so I'm wondering if there is a way to set this property in the TokBox "server side", as a session property, so the server would reject a new publisher if max. reached.

Please notice that I don't have any server state on my own that keeps track of the created sessions nor how many publishers they have, etc.

Thanks!


Solution

  • Adam here from the OpenTok team.

    There is no server-side setting available in OpenTok to limit the number of streams allowed. You could do something like I suggest in this answer though. Where you keep track of streamCreated Events and look at the creationTime property and if your stream is the n-th then you unpublish. Or you can forceUnpublish the n-th stream.