Actionscript 3 FMS Manager API class

I have been doing a bit of work recently using Flash Media Server 3.5 and was trying to find an actionscript 3 example of using the administrator api’s. I did not come across one in my searches so I am posting the one I created, it may help be of help to someone in the future.

?Download FMSAdmin.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.aileach.fms {
    import flash.events.*;
    import flash.net.Responder;
    import flash.net.NetConnection;
 
    public class FMSAdmin extends EventDispatcher {
 
        private var nc:NetConnection;
        private var remoteFMS:String;
 
        public function FMSAdmin() {
        /**
          Enter the rtmp server and address
        **/
        remoteFMS = "rtmp://[your_remoting_server]:[administrtor_port]/";
        }
 
        public function connectAdmin():void {
            nc = new NetConnection();
            nc.addEventListener(NetStatusEvent.NET_STATUS, connectionHandler);
            /**
               Enter the fms administraor username and password
            **/
            nc.connect( remoteFMS + "admin", "[administrator username]", "[administrator password]" );
            /**
              nc.call("[api function]", new Responder(returnedResult, failResult), [parameters]);
            **/
            nc.call("getUsers", new Responder(returnedResult, failResult), "[appinstance]");
        }
 
        /**
        * Outputs error if an invalid server details is used.
        */
        private function connectionHandler(ev:NetStatusEvent):void {
            if(ev.info.code == "NetConnection.Call.Failed") {
                trace("Unable to find gateway");
             }
        }
 
        /**
        * Handle successful results
        */
        private function returnedResult(obj:Object):void {
            trace("Call Successful");
        }
        /**
        * Handle failed results
        */
        private function failResult(obj:Object):void {
            trace("Call Failed");
        }
    }
}

In this example the call returns an array of strings that represent the server-assigned IDs of all users who are connected to the specified instance of an application. The result are returned in the function returnedResult. The obj.data is an array if the instance is active or as an error message if the instance is not active.

More details of available API’s can be found on the Adobe Flash Media Server Livedocs. This details the functions, parameters required and the results you should expect.

  1. Ciu says:

    where can’t find “com.aileach.fms” in your example, tankyou

  2. Mike says:

    Create a directory tree com.aileach.fms and put FMSAdmin.as in it, thats what gives the package the name.
    Project in Flex Builder

    You then import the class into your own actionscript pr MXML using import com.aileach.fms.FMSAdmin.
    Hope this helps.

  3. Binod says:

    Hi Can you tell me waht would be your_remoting_server let my fms is installed in binodonline.com prog files ……

  4. Mike says:

    It is usually the domain name of your FMS server in your case binodonline.com but sometimes I have had to use the IP address. Remember you must have FMS administrator access to do this, so check that you can logon using the FMS Administrator of your server first and the port is available to be accessed externally.

    Hope this helps, if you want to give me a little more information on exactly what you are trying to do, I may be able to point you in the right direction.

    Mike

  5. binod says:

    Thanx Mike,
    Let me tell you I have a dedicated server 2003 and there I installed FMS 3.5 . I can login into admistrater with user/pass. But I want to create one swf where I can see all the Running instance. and logs and all as it is in fms_adminConsole.htm.

    One more thing I would like to ask you If you can suggest me anything. I have a gaming application running with FMS can I make any other swf by which I can see any desire game running through admin panel as some movie is running respective to the game. Can I do that kind of thing.

    Thanks you much :)

  6. Mike says:

    Do you know there is an AIR application that allows you to access the administrator console ? Here is a link to the application and the supporting article. http://www.adobe.com/devnet/flashmediaserver/articles/fmis_feature_explorer.html

    If your game is using remote shared objects you should be able track what is happening on the game that by connection to its remote shared object, thats all I can think of.

  7. binod says:

    Thanks Mike let me go through the link you provided.
    Yes I have shared objects.

  8. Binod says:

    Hi Mike,
    I was lost ….
    Can u plz help me. I need to make a global script that can basically count how may clients are connected to rooms as I have n number of rooms created dynamically in the application.
    Plz help thnx

  9. Mike says:

    I had a similar problem in the past but the way I got around it was to create another shared object for the purpose of tracking connections to room names. I stored the room name and connections in an ArrayCollection. I do not know of any function which can track this specifically but creating a separate SharedObject worked for me.

line
footer
©Aileach Design 2009