0.1.0 • Published 8 years ago

causal-broadcast-definition v0.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

CausalBroadcastDefinition

Broadcasting component on top of a communication overlay. It includes a causality tracking mechanism before delivering messages to the application.

Installation

$ npm install causal-broadcast-definition

or

$ bower install causal-broadcast-definition

Usage

The module has been browserified and uglified. To include it within your browser, put the following line in your html:

  <script src='./build/causal-broadcast-definition.bundle.js'></script>
  <script src='./build/random-peer-sampling-example.bundle.js'></script>
  <script src='./build/causal-struct-example.bundle.js'><script>

In any case:

  var CausalBroadcast = require('causal-broadcast-definition');
  var RandomPeerSampling = require('random-peer-sampling-example');
  var CausalStruct = require('causal-struct-example');
  
  // #1 initialize the protocols
  var rps = new RandomPeerSampling(args1);
  var cs = new CausalStruct(args2);
  var delta = 3*60*1000; // interval between the anti-entropy rounds
  broadcast = new CausalBroadcast(rps, cs, myProtocolName, delta);

  // #2 define the receive event of broadcast causally ready
  broadcast.on('receive', function(message){
    console.log('I received the message: ' + message);
  });

  // #3 send a message to the whole network with causality metadata
  broadcast.send(toBroadcastMessage, messageUidCausality, messageUidDepending);

  // #4 it is the responsability of the application to retrieve old missed
  // request by the anti-entropy
  broadcast.on('antiEntropy', function(id,
                                       remoteCausalStruct,
                                       localCausalStruct){
    // #A retrieve the elements between remoteCausalStruct and localCausalStruct
    // #B send it back the causal broadcast
    broadcast.sendAntiEntropyResponse(id, localCausalStruct, elements);
  });
0.1.0

8 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago