Permalink
Browse files

simple echo remoting example, prints to browser console on 8082

  • Loading branch information...
1 parent c89d665 commit fe6c90548f729c967903a7bbee4a77a6369570f0 @cloudshift committed May 25, 2012
Showing with 8,127 additions and 0 deletions.
  1. +29 −0 usage/remotes/Client.hx
  2. +34 −0 usage/remotes/Server.hx
  3. +17 −0 usage/remotes/build.hxml
  4. +4,475 −0 usage/remotes/server.js
  5. +3,562 −0 usage/remotes/www/client.js
  6. +10 −0 usage/remotes/www/index.html
View
@@ -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);
+ });
+ }
+
+
+
+}
View
@@ -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);
+ }
+
+}
View
@@ -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()
Oops, something went wrong.

0 comments on commit fe6c905

Please sign in to comment.