I make simple server:
// Index.hx
package;
import neko.Lib;
import nekoserver.amf.AmfHandler;
import nekoserver.io.ResponseOutput;
import nekoserver.RemotingServer;
class Index
{
public function new() { }
public function echo(s: String): String {
return s;
}
static function main() {
var server:RemotingServer = new RemotingServer();
server.addHandler(new AmfHandler(true));
server.addObject("Index", new Index());
if (server.handleRequest())
return;
Lib.print("remoting server");
}
}
and simple Flex client:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="800" height="600" creationComplete="Init()" >
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import flash.net.Responder;
private function Init(): void {
//testNetConnection();
testRemoteObject();
}
private function testNetConnection():void {
var responder: Responder = new Responder(onSuccess, onError);
var netConnection: NetConnection = new NetConnection();
netConnection.objectEncoding = ObjectEncoding.AMF3;
netConnection.connect("http://localhost:2000/index.n");
netConnection.call("Index.echo", responder, "test");
}
private function onError(response:Object):void {
Alert.show(String(response), "Error");
}
private function onSuccess(response:Object):void {
Alert.show(response[0], "Response");
}
private function testRemoteObject():void {
echoService.echo("test");
}
]]>
</mx:Script>
<mx:RemoteObject id="echoService" destination="Index"
source="http://localhost:2000/index.n"
fault="Alert.show(event.fault.faultString, 'Error');">
<mx:method name="echo" result="Alert.show(event.result.toString(),
'Response');" />
</mx:RemoteObject>
</mx:Application>
When function 'testNetConnection' called, server correctly response, all ok.
When using mx:RemoteObject, then get the error:
[MessagingError message='Destination 'Index' either does not exist or the
destination has no channels defined (and the application does not define any
default channels.)']
How i can using RemoteObject with Neko server?
--
Neko : One VM to run them all
(http://nekovm.org)