I need to send complex type object (marked RemoteClass in Flex) via NetConnection to other clients.
[RemoteClass]
public class ComplexType
{
public var _someString:String;
public var _someInt:int;
}
... and using ...
_nc = new NetConnection();
_nc.connect("rtmp://localhost/echo/");
_nc.addEventListener(NetStatusEvent.NET_STATUS, _onNetStatus);
_nc.client = {};
_nc.client.echoCallback = _echoCallback;
var dto:ComplexType = new ComplexType();
dto._someInt = 4;
dto._someString = "abrakadabra";
_nc.call("echo", null, dto);
However it seems, that callback function on server side don't understand strongly typed objects and sends back this:
private function _echoCallback(...args):void
{
trace(ObjectUtil.toString(args));
/*
(Array)#0
[0] (Object)#1
_someInt = 4
_someString = "abrakadabra"
*/
}
Server side looks like this:
application.onAppStart = function () {
trace("Application.onAppStart > application started");
Client.prototype.echo = function (complexType /*ComplexType*/) {
trace("Client.echo > calling echo");
application.broadcastMsg("echoCallback", complexType);
}
}
Is there a way to relay strongly typed object via NetConnection?
EDIT1: added callback function source code with ObjectUtil.toString() output