Limiting number of visible streams

Ask any questions or talk about OpenTok here!

Limiting number of visible streams

Postby Camel » Mon Feb 21, 2011 9:30 am

Code: Select all
Archived Post


I've browsed around through the group but didn't find anything

specifically relating to this so I tried a few different approaches

on my own but I ran into a few different issues I haven't been able

to resolve.

The question I have is: is there an easy way to limit the number of

published streams per session? Even if I have a session with 100

people in it I want to only allow two people at a time to publish

their streams.

At first I tried making a counter on load which counts the number of

currently published streams and if that number is less than 2 then

we'll go ahead and publish and if it's 2 or greater then we don't

allow the publishing of the stream. The problem that I ran into there

is that if I had two users open the page at the same time and the

number of current streams equals 1 then their browsers might send the

publish request at the same time before the other user registers that

there are two streams leading to 3 streams total (which I don't

want).

Does that make sense?

Thoughts or pointers appreciated.
Was this post helpful? (0)
Camel
 

Limiting number of visible streams

Postby Thomas Osowski » Tue Feb 22, 2011 3:17 pm

Code: Select all
Archived Post


Hello

"...is there an easy way to limit the number of published streams per

session? Even if I have a session with 100 people in it I want to

only allow two people at a time to publish their streams..."

Limiting publishers for a session is a feature that has been logged

but I don't know if/when this will be scheduled.  If you know which

users will be publishing (and there are only two of them) you could

control this through our new token permissions.  Token permissions

can't be modified yet so this may not work if more than two users

will publish.  forceUnpublish could always be used to kick off the

last publisher whenever the three streams are detected though isn't

necessarily a long term solution.

Better yet the stream counting should be moved to the server-side

implementation that incorporates some sort of locking/semaphore to

guard changing the value. This is something I haven't tried yet and

might be moving beyond the scope of this group.

Is there a reason that the publishers are limited to two streams?

Thomas

tho...@tokbox.com

On Feb 21 8:30 am Camel <briansei...@gmail.com> wrote:

- Hide quoted text -
Was this post helpful? (0)
Thomas Osowski
 

Limiting number of visible streams

Postby Camel » Wed Feb 23, 2011 3:21 pm

Code: Select all
Archived Post


No other reason than that's how I want it to work at the moment. :)

I managed to get it to work to an extent by using some server-side

tracking. It keeps track of the participating tokens in the session

and only allows two tokens to be active at any given time. I'm sure

there are many many flaws around this way of doing it but it seems

to be working for now. The big problem that I have at the moment is

resetting the server-side tracking when someone leaves.

I currently have an event that detects when the browser closes or the

user leaves the page at which point it fires off an AJAX call to the

server and lets it know that the user disconnected but I can imagine

it's possible that this won't catch every possible circumstance. It

also sends the same message when the session and/or stream is

Destroyed (via the sessionDestroyedHandler etc).

It's not perfect but maybe it'll work until I can come up with a

better solution.

Thanks.

On Feb 22 5:17 pm Thomas Osowski <tho...@tokbox.com> wrote:

- Hide quoted text -
Was this post helpful? (0)
Camel
 


Return to Discussion and Questions



Who is online

Users browsing this forum: No registered users and 1 guest

cron