Skip to main content
Inspiring
Oct 12, 2010 11:40 AM UTC
Answered

Restricting number of viewers

Hi SE_0208

Just following up from my previous thread.

I wanted to know how to restrict the number of viewers for an application.

I tried this

{

if(application.clients.length > 10)

  application.rejectConnection(client)

}

I put that inside application.onAppStart = function()  - but it didn't work

I'm not sure if I'm putting it in the right place!

Can you suggest something else? Thanks

    This topic is closed to new replies. Start a new post to keep the conversation going.
    SE_0208Correct answer
    Participating Frequently
    Oct 12, 2010 12:18 PM UTC

    You need to place it in application.onConnect handler so in your case it would like

    application.onConnect = function( p_client, p_autoSenseBW )

    {

    if(application.clients.length > 10)

      application.rejectConnection(p_client)

    else

    {

         //rest of onCOnnect code

    }

    }

    2 replies

    SE_0208Correct answer
    Participating Frequently
    Oct 12, 2010 12:18 PM UTC

    You need to place it in application.onConnect handler so in your case it would like

    application.onConnect = function( p_client, p_autoSenseBW )

    {

    if(application.clients.length > 10)

      application.rejectConnection(p_client)

    else

    {

         //rest of onCOnnect code

    }

    }

    Translate
    kaka2koolAuthor
    Inspiring
    Oct 12, 2010 12:51 PM UTC

    Brilliant, that works just as I wanted. Thanks again for your kind help, much appreciated!

    Translate