p2p

library for p2p communication
https://github.com/peteshand/p2p

To install, run:

haxelib install p2p 0.1.44 

See using Haxelib in Haxelib documentation for more information.

README.md

P2P

WARNING: Not production ready

The aim of this library is to offer a simple way to setup a p2p communication layer.

This library is currently in the early stages of development, therefore I wouldn't recommend using this for anything in production.

Goal

The goal of this library is to create a standardize Peer to Peer API that can be layered on top of multiple types of communication protocols.

Installing a communication layer

P2P.install(ICommunication);

Notifier Binding API

As the name suggest notifier binding allows you to bind a notifier to a string Id and then have it synchronise over the p2p network when it's value is changed.

Listen for changes with Id 'test' and assign value to notifier

P2P.bind(notifier, 'test', P2P.IN);

Listen for value changes on notifier and when it updates broascast it's value over the network with Id 'test'.

P2P.bind(notifier, 'test', P2P.OUT);

Both listen and broadcast

P2P.bind(notifier, 'test', P2P.IO);

.....

notifier1.add((value:Int) -> {
	trace("value = " + value);
}
var notifier1:Notifier<Int> = new Notifier<Int>(0);
P2P.addSubscriber(notifier1, 'test');
var notifier1:Notifier<Int> = new Notifier<Int>(0);
P2P.addBroadcast(notifier1, 'test');

notifier1.value = 2;

Basic listener and sender API

P2P.listen("messageId", (payload:{foo:String}) -> {
	trace("payload.foo = " + payload.foo);
});
var payload = {
	foo:"bar"
};
P2P.send("messageId", payload);
Contributors
p.j.shand
Version
0.1.44
Published
6 years ago
Dependencies
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂