Skip to main content
Known Participant
November 11, 2009
Answered

Administration api

  • November 11, 2009
  • 1 reply
  • 1214 views

This call don't work:

var nc:NetConnection;
nc = new NetConnection();
nc.connect("rtmp://localhost:1111/admin","usernameadmin","passwordadmin");
nc.addEventListener(NetStatusEvent.NET_STATUS, connectionHandler);

function connectionHandler(event:NetStatusEvent):void {
trace(event.info.code);
// "function too call" , "folder-app", "stream-name"
nc.call("getNetStreamStats", "live" , "livefeed");

}

return dis error:

1067: Implicit coercion of a value of type String to an unrelated type flash.net:Responder.

i'm novice with as3 please help me

tank

    This topic has been closed for replies.
    Correct answer
    Thanks again for your great help
    I changed from getNetStreamStats to getLiveStreamStats and works

    When the livestreams is off line

    the trace response is : NetConnection.Admin.CommandFailed  -  why ?

    When the livestreams is online

    the trace response is : NetConnection.Call.Success

    how to get all those little details that I get when I make the call

    via http ?

    <?xml version="1.0" encoding="utf-8" ?>

    - <result>
    <level>status</level>
    <code>NetConnection.Call.Success</code>
    <timestamp>12/11/2009 11.40.52</timestamp>
    - <data>
    <name>_defaultRoot_:_defaultVHost_:::_1</name>
    - <publisher>
    <name>myVideo</name>
    <time>12/11/2009 11.40.40</time>
    <type>publishing</type>
    <client>DCAggiZC</client>
    <stream_id>DBAggiZC</stream_id>
    <client_type>normal</client_type>
    <publish_time>12/11/2009 11.40.40</publish_time>
    </publisher>
    <subscribers />
    </data>
    </result>

    I added textarea component and i'm edit the code in this mode:

    ......

    function admin_callback_result(info:Object) {
    // get the info object properties in this method.
    // ex. trace(info.code);  will trace if the call succeeded or no.
    trace(info.code);

    for (var prop in Object) {
      destination.text=prop;
    }
    }

    but I can not see anything
    tank you

    Hi,

    With getLiveStreamStats command you are trying to query stats for a Livestream which is currently active. And hence when the livestream you are trying to derive stats for, is not active, the command will fail with NetConnection.Admin.CommandFailed.

    To obtain all the details from the object received in admin_callback_result( ), you could use something like this :

          for (prop in info.data) {
               destination.text+=prop + ":" + info.data[prop]+"\n";
                        for (prop1 in info.data[prop]) {
                            destination.text+=prop1+":"+info.data[prop][prop1]+"\n";

                        }

         }

    Thanks

    Mamata

    1 reply

    Participating Frequently
    November 11, 2009

    Hi,

           The error you have listed below is a client side Actionscript error. You need to define a Responder object variable to hold the callback result from the call you issued to the admin server. The code snippet is some thing like this:

    var nc:NetConnection;
    nc = new NetConnection();
    nc.connect("rtmp://localhost:1111/admin","usernameadmin","passwordadmin");
    nc.addEventListener(NetStatusEvent.NET_STATUS, connectionHandler);

    function connectionHandler(event:NetStatusEvent):void {
    trace(event.info.code);
    // "function too call" , "folder-app", "stream-name"
    nc.call("getNetStreamStats",myResponder, "live" , "livefeed");

    }

    var myResponder:Responder = new Responder(admin_callback_result);

    function admin_callback_result(info:Object){

              // get the info object properties in this method.

              // ex. trace(info.code);  will trace if the call succeeded or no.

    }

    Please reply back in case you have queries.

    Thanks

    CMCadIDAuthor
    Known Participant
    November 11, 2009

    First I want to say thanks for your help

    I immediately tried his code and it seems to work

    only that in the output window compare this:
    NetConnection.Connect.Success - I believe that this message and the first trace
    NetConnection.Call.BadValue - and this for second trace
    I only changed this on its code
    from so
    //ex.trace(info.code);
    to so
    trace(info.code);
    for view the trace in output code
    my final code in the page is this:

    var nc:NetConnection;
    nc = new NetConnection();
    nc.connect("rtmp://localhost:1111/admin","usernameadmin","passwordadmin");
    nc.addEventListener(NetStatusEvent.NET_STATUS, connectionHandler);

    function connectionHandler(event:NetStatusEvent):void {
    trace(event.info.code);
    // "function too call" , "folder-app", "stream-name"
    nc.call("getNetStreamStats",myResponder, "live" , "livefeed");

    }

    var myResponder:Responder = new Responder(admin_callback_result);

    function admin_callback_result(info:Object){

              // get the info object properties in this method.

              ex. trace(info.code);  //will trace if the call succeeded or no.

    }

    I would say when I make the call via http in this mode:
    http://localhost:1111/admin/getLiveStreamStats?auser=usernameadmin&apswd=passwordadmin&appInst=live&stream=livefeed
    everything works great
    tankyou e please help me
    Participating Frequently
    November 12, 2009

    Hi,

           The commands getLiveStreamStats and getNetStreamStats take different parameters. getLiveStreamStats takes the streamName pwarameter where as the getNetStreamStats takes "streamids" as the parameter. Also please refer the flashmediaserver_3.5_administrationAPI.pdf doccumentation thats's  available below flash media server installation directory.

    The command http://localhost:1111/admin/getNetStreamStats?auser=admin&apswd=admin&appInst=live&streamids=-1 will work correctly. The doc says "To get information for all the network streams that are currently connected, specify a value of -1 for the streamids parameter"

    So when you do a call using action script just pass the parameter as -1 in the nc.call(). Some thing like this nc.call ("getNetStreamStats",myResponder, "live", -1);

    then in the admin_callback_result() method traceing the info["code"] should return you "NetConnection.Call.Success" and if you trace the trace(info["data"][0]["name"]); this should trace you "liveFeed"(the name of the stream).

    I would suggest you to go through the flashmediaserver_3.5_administrationAPI.pdf for more information.

    Please reply back in case of any queries.

    Thanks

          Viraj