Skip to main content
Inspiring
October 12, 2010
Answered

Restricting number of viewers

  • October 12, 2010
  • 1 reply
  • 418 views

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 has been closed for replies.
    Correct answer SE_0208

    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

    }

    }

    1 reply

    SE_0208Correct answer
    Participating Frequently
    October 12, 2010

    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

    }

    }

    kaka2koolAuthor
    Inspiring
    October 12, 2010

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