Coder Social home page Coder Social logo

p2p's Introduction

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);

p2p's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

datee longde123

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.