milton

0.0.2 • Public • Published

milton

Build Status

Overview

Milton is a publish subscribe client and server for node.js based on the scuttlebutt event emitter. Clients can recieve new events from any other connected client. Install globally and run 'milton' to launch the milton server, clients can connect to the server to emit and recieve events.

Launch the server manually and replicate with remote process' to create a mesh network.

install

npm install milton -g

Server

Launch a local instance

milton

Launch a local server and replicate with a remote milton server

milton -p 9999 --replicate 192.168.0.1:8000

# dont use spaces if passing an array
milton -p 9998 -r ['192.168.0.1:8000','127.0.0.1:9999']

Library usage

 
var milton = require('milton/client');
    
var client = milton({ port: 8000 });
 
var event = {
    demo: true
};
 
process.nextTick(function () {
    client.emit('demo', event);
});
    
client.on('demo', function (data) {
    console.log('[recieved] ', data);
});
 

As a pull stream sink

var pull = require('pull-stream');
var sink = require('milton/pull/sink')();
 
pull(
    pull.values([ { demo: true } ]),
    sink('demo_channel')
)
 

As a pull stream source

var pull   = require('pull-stream');
var source = require('milton/pull/source')();
 
pull(
    source('demo_channel'),
    pull.log()
)
 

Peer to peer

Manually create servers and replicate with remote processes to create a peer to peer mesh.

var server = require('milton/server')();
 
// create a milton server manually 
// and replicate with a remote milton server...
//
server.start(8000, function () {
    server.replicate('192.168.0.100', 9000);
});
 

Package Sidebar

Install

npm i milton

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • m-onz