Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upThe `webtorrent` module should work with browserify #88
Comments
This comment has been minimized.
This comment has been minimized.
|
This is fixed as of webtorrent 0.6.0. Now Here's an example of how to use WebTorrent: var dragDrop = require('drag-drop/buffer')
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
// when user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', function (files) {
client.seed(files, onTorrent)
})
function onTorrent (torrent) {
console.log('Torrent info hash: ' + torrent.infoHash)
// go through each file in the torrent, create a link to it, and add it to the DOM
torrent.files.forEach(function (file) {
file.createReadStream().pipe(concat(function (buf) {
var a = document.createElement('a')
a.download = file.name
a.href = URL.createObjectURL(new Blob([ buf ]))
a.textContent = 'download ' + file.name
document.body.appendChild(a)
}))
})
}
// call this function to download a torrent!
function download (infoHash) {
client.download({
infoHash: infoHash,
announce: [ 'wss://tracker.webtorrent.io' ]
}, onTorrent)
} |
This comment has been minimized.
This comment has been minimized.
|
Added this example code to the main readme! |
This comment has been minimized.
This comment has been minimized.
|
Nice ! |
This comment has been minimized.
This comment has been minimized.
|
Yep! Updated the readme. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
To use WebTorrent right now, you need to use
bittorrent-client, the module whichwebtorrentuses internally. This is becausewebtorrentis currently doing a bunch of node-specific things like reading from the filesystem and starting an http server.Let's use the browser field spec to exclude these files so people can just do
require('webtorrent')