Last active
January 28, 2019 08:29
-
-
Save okdistribute/6c0594ae9fc215d2b750c39e7e4f8973 to your computer and use it in GitHub Desktop.
dat with webrtc
This file contains hidden or 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
var webrtc = require('webrtc-swarm') | |
var signalhub = require('signalhub') | |
var hyperdrive = require('hyperdrive') | |
var memdb = require('memdb') | |
var pump = require('pump') | |
var DEFAULT_SIGNALHUBS = 'https://signalhub.mafintosh.com' | |
var drive = hyperdrive(memdb()) | |
var archive = drive.createArchive() | |
var swarmKey = 'dat-' + archive.discoveryKey.toString('hex') | |
var swarm = webrtc(signalhub(swarmKey, DEFAULT_SIGNALHUBS)) | |
swarm.on('peer', function (peer) { | |
var peer = archive.replicate({ | |
upload: true, | |
download: true | |
}) | |
pump(conn, peer, conn) | |
}) |
This file contains hidden or 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
{ | |
"name": "webrtc-example", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"hyperdrive": "^7.14.2", | |
"memdb": "^1.3.1", | |
"pump": "^1.0.2", | |
"signalhub": "^4.8.0", | |
"webrtc-swarm": "^2.8.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment