views:

177

answers:

2

I have following object in the FMS

User = function(userName,userId)

{

this.userName = userName;

this.userId = userId;

}

I need to send the list of user to the client swf. Once I initialized the User object collection to an array, array element is undefined when I read it from the client.

However I can’t send the generic object too. Once I initialized the array elements in Objects as follow. It also give the undefined in the client side.

var myObj = {userName:"user1name", userId:"user1id"};

But following works

var arr2 = [];

arr2["userName"] = "user1name "; arr2["userId "] = " user1id";

Clients are connected to the main application on the FMS. Then it connect to second application through NetConnection. And I have mapped the remote method using the ‘registerProxy’ feature.

Eg: application.registerProxy(localName,this._nc,remoteName);

Above described method in the second application. I’m using Actionscript 2 for client side.

Any solution for the matter is highly appreciated.

Thanks in advance.

A: 

As far as I know, there is no way to map client-side classes to server-side FMS classes. In AS2 this functionality was simply absent, as far as I remember the old times.

I've tried your example with AS3. Passing objects (though untyped) works with FMS 3.5.

Client-side:

private var nc:NetConnection;
private function init():void  {
    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    nc.connect("rtmp:/test");
}
private function netStatusHandler(event:NetStatusEvent):void {
    trace(event.info.code);
    if(event.info.code == "NetConnection.Connect.Success") {
        var responder:Responder = new Responder(resultHandler);
        nc.call("getUser", responder, "hrundik", 1234);
    }
}
private function resultHandler(result:Object):void {
    if(result)
        trace(result.userName, result.userId);
}

Server-side:

User = function(userName,userId) {
    this.userName = userName;
    this.userId = userId;
}
application.onConnect = function (client) {
    trace("client connected!");
    client.getUser = function(userName, userId) {
        return new User(userName, userId);
    }
    return true;
}

The reason in differences between AS2 and AS3 might be in object encoding protocol being used - AMF0 vs AMF3. Although, AMF0 works as expected in AS3.

So, perhaps, consider porting your application to AS3.

Hrundik
A: 

Thanks, However you gave me good hint :) Problem in the inter application NetConnection on the FMS Server. By default FMS 3 uses the AMF3 serialization. Since my client application AS2, I have change the the ObjectEncoding Application.xml on FMS

eg. <ObjectEncoding>AMF0</ObjectEncoding>

Erandac