KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
p2p-hub
★ 11
Open GitHub ↗
a peer to peer hub of json connections
Download README (.md)
Explore Similar Repositories
CZMQ
:
D Bindings for High-Level C wrapper for ZeroMQ
CafeTownsend-Spine
:
CoffeeScript (Spine) port of the famous Cafe Townsend demo originally written in ActionScript
book-curie-radio-de
:
source code of book M. Curie: Untersuchungen über radioaktive Substanzen", 1904
PyDDnsPod
:
A python script for DDNS using the service of DNSPod
Ponifuse
:
Ponifies files at load and de-ponifies them at write time (fuse module)
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
p2p-hub
?
Download (.md)
# p2p-hub a super simple p2p hub that allows you to send json messages between computers ``` js var hub = require('p2p-hub').connect('json://address_to_a_member'); hub.on('connect', function(from) { console.log(from, 'connected'); // let's print all current nodes var all = hub.nodes(); console.log('all nodes:', all); // let's say hello to him hub.send(from, {hello:'world'}); }); hub.on('disconnect', function(from) { console.log(from, 'disconnected'); }); hub.on('message', function(from, message) { console.log(from, 'says', message); }); hub.send('json://another_member', {hello:'world'}); ``` You can also multiplex messages to support multiple apps on the same hub ``` js var hub = require('p2p-hub').connect('json://address_to_a_member'); var app = hub.multiplex('app'); app.on('connect', function(from) { console.log(from, 'connected to app'); console.log('all in app:', app.nodes()); }); app.on('disconnect', function(from) { console.log(from, 'disconnected from app'); }); app.on('message', function(from, message) { console.log(from, 'in app says', message); }); app.send('json://another_member', {hello:'app'}); ```