Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple echo remoting example, prints to browser console on 8082
- Loading branch information
1 parent
c89d665
commit fe6c905
Showing
6 changed files
with
8,127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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); | |||
}); | |||
} | |||
|
|||
|
|||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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); | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.