Skip to content

Commit

Permalink
simple echo remoting example, prints to browser console on 8082
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudshift committed May 25, 2012
1 parent c89d665 commit fe6c905
Show file tree
Hide file tree
Showing 6 changed files with 8,127 additions and 0 deletions.
29 changes: 29 additions & 0 deletions usage/remotes/Client.hx
@@ -0,0 +1,29 @@

package ;

import cloudshift.Core;
using cloudshift.Mixin;


class ClientProxy extends haxe.remoting.AsyncProxy<Server>{}

class Client {


static function main() {
new Client();
}

public function new() {
var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://localhost:8082/remotes");
cnx.setErrorHandler( function(err) trace("Error : "+Std.string(err)) );
var p = new ClientProxy(cnx.Test);

p.echo("woot",function(s) {
trace("client return:"+s);
});
}



}
34 changes: 34 additions & 0 deletions usage/remotes/Server.hx
@@ -0,0 +1,34 @@

package ;

#if nodejs
import cloudshift.Core;
import cloudshift.Http;
import cloudshift.Remote;
using cloudshift.Mixin;
#end

class Server {

static function main() {
new Server();
}

public function new() {
#if nodejs
Http.server()
.root("www")
.start({host:"localhost",port:8082})
.outcome(function(http) {
trace("Creating remote");
var remotes = Remote.provider("Test",this);
http.handler(new EReg("/remotes",""),remotes.httpHandler);
});
#end
}

public function echo(s:String,cb:String->Void) {
cb(s);
}

}
17 changes: 17 additions & 0 deletions usage/remotes/build.hxml
@@ -0,0 +1,17 @@

-main Server
-cp ../../
-cp .
-lib nodejs
-D CS_SERVER
-js server.js
--macro cloudshift.core.JSGenerator.use()

--next

-main Client
-cp .
-cp ../../
-D CS_BROWSER
-js www/client.js
--macro cloudshift.core.JSGenerator.use()

0 comments on commit fe6c905

Please sign in to comment.