Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torrent event never emited #802

Closed
Lunik opened this issue May 15, 2016 · 3 comments
Closed

Torrent event never emited #802

Lunik opened this issue May 15, 2016 · 3 comments

Comments

@Lunik
Copy link
Contributor

@Lunik Lunik commented May 15, 2016

Hi ! Same as #749

  • WebTorrent version: 0.93.3
  • Node.js version: V6.1.0
var WebTorrent = require('webtorrent')
var client = new WebTorrent()

var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d&dn=sintel.mp4&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&tr=wss%3A%2F%2Ftracker.webtorrent.io&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel-1024-surround.mp4'

client.add(torrentId, function (torrent) {
  // Torrents can contain many files. Let's use the first.
  var file = torrent.files[0]

  // Display the file by adding it to the DOM. Supports video, audio, image, etc. files
  torrent.on('infoHash', function() { console.log('infoHash') })
  torrent.on('metadata', function() { console.log('metadata') })

  torrent.on('ready', function() {
    console.log('ready')
    torrent.on('done', function() { console.log('done') })
    torrent.on('download', function() { console.log('download') })
    torrent.on('wire', function() { console.log('wire') })
  })
})

infoHash, metadata and ready are never emitted...

@Lunik

This comment has been minimized.

Copy link
Contributor Author

@Lunik Lunik commented May 15, 2016

I figured out in:

var torrent_1 = client.add(magnet, function(torrent_2){
})

That torrent_1 is different that torrent_2

@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented May 15, 2016

They are the same, it's just that infoHash, metadata and ready are emitted before the callback of client.add is called. Accessing it sync let's you access those events.

That's why the full way to do it is: #749 (comment)

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.