Prev | Current Page 814 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

id == id)
return person;
return null;
}
}
Part II: Server Side, JavaScript, and Flash: Oh My!
440
The Server class to implement the HTTP Server is very simple. An instance of the PersonDatabase is
registered on the RemotingServer using the addObject method.
class Server
{
public static function main()
{
var server = new neko.net.RemotingServer();
server.addObject(???PersonDatabase???, new PersonDatabase());
if(server.handleRequest())
return;
// handle other requests (not remoting)
neko.Lib.print(???Neko remoting server waiting for a request???);
}
}
Although the objects must be explicitly registered to be used by a client, their methods are all available.
It is possible to restrict the access to certain methods using the setPrivatePrefix() on the
RemotingServer() instance. All methods starting with the specified prefix cannot be directly
invoked by a client.
The client code uses an AsyncConnection to communicate with the server. First the whole list of
persons is loaded using listIds() . The method has a reference to the fillList() function as
argument.


Pages:
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826