Skip to content

Instantly share code, notes, and snippets.

@AxGord
Last active January 15, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AxGord/ff85d5ad4465f5634155de1f6bc78632 to your computer and use it in GitHub Desktop.
Save AxGord/ff85d5ad4465f5634155de1f6bc78632 to your computer and use it in GitHub Desktop.
import pony.net.*;
import pony.net.rpc.*;
import pony.events.*;
import pony.time.MainLoop;
class RPCExample {
private static function main():Void {
MainLoop.init();
var server = new ExampleProtocol(new SocketServer(12345));
var client = new ExampleProtocol(new SocketClient(12345));
server.onMessage.add((message:String) -> trace('Received: $message'));
server.onMessage.add(MainLoop.stop);
client.messageRemote('hello');
MainLoop.start();
}
}
class ExampleProtocol extends RPC<ExampleProtocol> implements IRPC {
@:rpc public var onMessage:Signal1<String>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment