GithubHelp home page GithubHelp logo

tnwinc / haxe_remoting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dionjwa/haxe_remoting

0.0 7.0 0.0 224 KB

Additional asynchronous remoting tools for haxe.

Haxe 98.10% Shell 0.09% Python 1.82%

haxe_remoting's Introduction

Asynchronous remoting classes for Haxe

This package consists of:

  1. Node.js remoting connections, one using NodeRelay (thanks Bruno Garcia), the other not.
  2. Macros to build async client proxy remoting classes from interfaces or the server remoting class. All server classes are excluded from the client.
  3. Flash <-> JS asynchronous remoting connection (ExternalAsyncConnection)
  4. Websocket wrappers for passing both JSON and Haxe serialized objects between a websocket client and server (Node.js)

See the demo for a working example.

Installation/compilation

To build the demos:

  1. Install node.js.

  2. Install flambe.

  3. Configure and run wafl (in the library root):

    wafl configure --debug wafl install

To run the remoting demo:

  • In one terminal window run the server:

    node deploy/remoting-server/server.js

  • In another terminal window, run the client:

    node deploy/remoting-server/client.js

In the client window, type a number and then enter. The server sends back a processed result.

Usage (building your own remoting classes)

Assume you have a remoting class on the server:

package foo;

@:build(transition9.remoting.Macros.remotingClass())
class FooRemote
{
	@remote
	public function getTheFoo(fooId :String, cb :String->Void) :Void
	{
		cb("someFoo");
	}
}

On the client, you can construct a fully typed proxy async remoting class with:

//Create the remoting Html connection
var conn = haxe.remoting.HttpAsyncConnection.urlConnect("http://localhost:8000");

//Build and instantiate the proxy class with macros.  
//The full path to the server class is given as the first argument, but it is NOT compiled into the client by default
var fooProxy = transition9.remoting.Macros.buildAndInstantiateRemoteProxyClass(foo.FooRemote, conn);

//You can use code completion here
fooProxy.getTheFoo("fooId", function (foo :String) :Void {
	trace("successfully got the foo=" + foo);
});

Instead of a remoting class, you can also build the proxy from an interface:

interface FooRemote
{
	@remote
	public function getTheFoo(fooId :String, cb :String->Void) :Void;
}

You can also create an interface from the remoting class:

@:build(transition9.remoting.Macros.addRemoteMethodsToInterfaceFrom(foo.FooRemote))
interface FooService {}

Then the client proxy class is declared with

@:build(transition9.remoting.Macros.buildAsyncProxyClassFromInterface(FooRemote))
//Or @:build(transition9.remoting.Macros.buildAsyncProxyClassFromInterface("foo.FooRemote"))
class FooProxy implements IRemotingService {}:

In the future, you will be able to build and instantiate the interface derived proxy the same as the class derived proxy above.

Running the unit tests

There are two unit tests:

./test/runtests.sh

Coming soon:

Websockets. Relies on the flambe lib.

To run the websocket demo:

  • In one terminal window run the server:

    node deploy/websocket-server/server.js

  • In another terminal window, run the first client:

    node deploy/websocket-server/client.js

  • Finally in a third terminal window, run the second client:

    node deploy/websocket-server/client.js

haxe_remoting's People

Contributors

dionjwa avatar jasononeil avatar

Watchers

Brendan Erwin avatar Jace Bennett avatar Ricardo Diaz avatar Steve White avatar James Cloos avatar Randall Borck avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.