Skip to content

Chat-Wane/CausalBroadcastDefinition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Well, that seems to be the situation. But I don't want that. And you don't want that. And Ringo here *definitely* doesn't want that.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published