Skip navigation
poojapooja
Currently Being Moderated

AppStats using onGetAppStats() in main.asc

Apr 3, 2012 10:29 PM

Tags: #statistics

Hi,

I am trying to collect appstats using this code in main.asc.

What is wrong here?

 

application.onConnect = function( p_client, p_autoSenseBW )

{

     this.acceptConnection(p_client);

   

     nc_poll=new NetConnection();

     nc_poll.connect("rtmp://localhost:1111/admin","admin","a1s2d3f4");

     nc_poll.call("getAppStats",new onGetAppStats(), "vod");   

    

    function onGetAppStats()

    {

    this.onResult = function(info)

    {

      trace("POOJA 1111");

      outputBox.text = "Info for "+appName.text+ " returned:" + newline;

      trace("POOJA 2222");

      printObj(info, outputBox);

     

    }

 

    }

 

    function printObj(obj, destination)

    {

     trace("POOJA 3333");

     for (var prop in obj)

    {

     destination.text += "\t";

     destination.text += prop + " = " + obj[prop] + newline;

     if (typeof (obj[prop]) == "object")

     {

     trace("POOJA 4444");

      printObj(obj[prop], destination);

     }

   }

  }

   

}

 

thanks

 
Replies
  • Currently Being Moderated
    Apr 4, 2012 8:54 AM   in reply to poojapooja

    1. Wait for the onStatus event from the NetConnection before invoking methods. Otherwise, you may be calling a method on a netconnection that hasn't been completed.

     

    2. Are you defining the nc_poll variable outside of the onConnect method? If not, the scope of nc_poll is the onConnect function, so when the function returns, the nc_poll variable will have gone out of scope, and will be eligible for garbage collection.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 8:26 AM   in reply to poojapooja

    You're still calling getAppStats on the connection without being sure the connection is established. Invoke a method outside of onConnect in response to the onStatus event.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 4:30 AM   in reply to poojapooja

    Create the connection in your onAppStart method, rather than the onConnect method.

     

    Alternately, you can create a new class to manage this, and instantiate an instance of that class in your onAppStart.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points