Skip to content

Commit

Permalink
linking stuff together
Browse files Browse the repository at this point in the history
  • Loading branch information
Chat-Wane committed Jan 5, 2015
1 parent 3fe1e05 commit 131e3cf
Show file tree
Hide file tree
Showing 5 changed files with 15,536 additions and 0 deletions.
56 changes: 56 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<html>
<head> <title>SCAMPjs</title> </head>
<body>
<textarea rows="5" cols="80" id="textID"></textarea> <br/>
<button type="button" id="offer">1. Make offer</button>
<button type="button" id="join">2. Accept offer</button>
<button type="button" id="handshake">3. Confirm handshake</button>
<br/> <!-- ugly but whatever, just an example -->
<br/>
<br/>
<div id="log"></div>

<script src="./jquery-2.1.1.min.js"></script>
<script src="../rtc-scamp.bundle.js"></script>
<script>
var Network = require('rtc-scamp');
var n = new Network(Math.floor(Math.random()*1000));
console.log("n = ",n);
var membership = n._membership;

$("#offer").click(function(){membership.launch()});
$("#join").click(function(){
var message = JSON.parse($("#textID").val());
membership.answer(message);
});
$("#handshake").click(function(){
var message = JSON.parse($("#textID").val());
membership.handshake(message);
});

setInterval( function(){
n.broadcast("hello my name is "+ n._broadcastDefinition.ivv.local.e);
}, Math.floor(Math.random()*5000)+15000 );

// setInterval( function(){
// var rn = Math.floor(Math.random()*p.partialView.length());
// var message = {payload:"private message from "+p.uid};
// p.send(message, p.getPeers(1).link);
// }, Math.floor(Math.random()*10000)+15000 );


membership.on("launch", function(message){
$("#textID").val(JSON.stringify(message));
});

membership.on("answer", function(message){
$("#textID").val(JSON.stringify(message));
});

n.on("receive", function(message){
$("#log").html( $("#log").html() + message + "<br/>" );
});

</script>
</body>
</html>
4 changes: 4 additions & 0 deletions example/jquery-2.1.1.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions lib/network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var SCAMP = require("rtc-scamp-mbr");
var IVVBroadcast = require("ivv-broadcast-definition");
var Network = require("p2pnetwork");

module.exports = function(uid){
return Network.init({broadcastDefinition:new IVVBroadcast(uid),
membership:new SCAMP(uid)});
};
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "rtc-scamp",
"version": "0.0.1",
"author": "Chat-Wane <[email protected]>",
"description": "Gossip-based dissemination protocol using the SCAMP membership management that automatically scales with the global size of the network without global knowledges.",
"main": "./lib/network.js",
"repository": {
"type": "git",
"url": "https://github.com/chat-wane/SCAMP-rtc.git"
},
"keywords": [
"gossip",
"broadcast",
"scamp",
"webrtc"
],
"dependencies": {
"ivv-broadcast-definition": "0.0.x",
"rtc-scamp-mbr": "0.0.x",
"p2pnetwork": "0.0.x"
},
"bundledDependencies": [
"ivv-broadcast-definition",
"rtc-scamp-mbr",
"p2pnetwork"
],
"license": "MIT",
"engines": {
"node": ">=0.10.35"
}
}
Loading

0 comments on commit 131e3cf

Please sign in to comment.