-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
15,536 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Oops, something went wrong.