RemotingServer.hx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package unit;
  2. class RemotingServer extends neko.net.ThreadRemotingServer {
  3. static var HOST = "dev.unit-tests";
  4. static var PORT = 1999;
  5. override function initClientApi( cnx : haxe.remoting.SocketConnection, ctx : haxe.remoting.Context ) {
  6. RemotingApi.context(ctx);
  7. cnx.setErrorLogger(function(path,args,e) {
  8. // ignore invalid calls or exceptions in methods
  9. });
  10. }
  11. override function onXml( cnx : haxe.remoting.SocketConnection, data : String ) {
  12. if( data == "<policy-file-request/>" ) {
  13. var str = "<cross-domain-policy>";
  14. str += '<allow-access-from domain="'+HOST+'" to-ports="'+PORT+'"/>';
  15. str += "</cross-domain-policy>";
  16. str += "\x00";
  17. cnx.getProtocol().socket.write(str);
  18. return;
  19. }
  20. super.onXml(cnx,data);
  21. }
  22. static function main() {
  23. if( neko.Web.isModNeko ) {
  24. var ctx = RemotingApi.context();
  25. if( !haxe.remoting.HttpConnection.handleRequest(ctx) )
  26. throw "Invalid request";
  27. return;
  28. }
  29. var s = new RemotingServer();
  30. trace("Starting server on "+HOST+":"+PORT);
  31. s.run(HOST,PORT);
  32. }
  33. }