Skip to content

Commit

Permalink
use webtorrent-swarm
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Aug 11, 2014
1 parent d9a2472 commit b9a4f11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013 Feross Aboukhadijeh
Copyright (c) Feross Aboukhadijeh

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
19 changes: 8 additions & 11 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var createTorrent = require('create-torrent')
var debug = require('debug')('instant.io')
var dragDrop = require('drag-drop')
var hat = require('hat')
var parseTorrent = require('parse-torrent')
var Tracker = require('webtorrent-tracker/client')
var Swarm = require('webtorrent-swarm')

// Force-add webtorrent tracker
createTorrent.announceList.push(['ws://tracker.webtorrent.io:9002'])
Expand All @@ -26,18 +27,14 @@ function newTorrent (files) {
a.textContent = 'download .torrent'
document.body.appendChild(a)

var peerId = new Buffer('01234567890123456789')
var tracker = new Tracker(peerId, parsedTorrent)
var peerId = window.peerId = new Buffer(hat(160), 'hex')
debug('peer id %s', peerId.toString('hex'))

tracker.on('warning', function (err) {
console.log('tracker warning', err)
var swarm = new Swarm(parsedTorrent, peerId)
swarm.on('wire', function (wire) {
debug('got wire')
window.wire = wire
})

tracker.on('error', function (err) {
console.log('tracker error', err)
})

tracker.start()
})
}

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
"debug": "^1.0.4",
"drag-drop": "^1.0.2",
"express": "^4.7.2",
"hat": "0.0.3",
"inherits": "^2.0.1",
"jade": "^1.5.0",
"node-static": "^0.7.3",
"once": "^1.3.0",
"parse-torrent": "^1.7.0",
"posix": "^1.0.3",
"simple-peer": "^1.0.0",
"webtorrent-swarm": "^0.1.1",
"webtorrent-tracker": "^0.1.0"
},
"devDependencies": {
Expand Down

0 comments on commit b9a4f11

Please sign in to comment.