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.on events of client.seed and client.add #749

Closed
Tercus opened this issue Apr 11, 2016 · 4 comments
Closed

torrent.on events of client.seed and client.add #749

Tercus opened this issue Apr 11, 2016 · 4 comments

Comments

@Tercus
Copy link
Contributor

@Tercus Tercus commented Apr 11, 2016

  • WebTorrent version: 0.86.2
  • Node.js version: 5.10.1

I have the following testcode:

client.seed(torrentfile, { announceList: [['ws://localhost:8080']] }, onseed)
function onseed (torrent) {
    console.log('onseed getting called')
    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') })
}
client.on('torrent', function (torrent) {
    console.log('client.on getting called')
    torrent.on('infoHash', function() { console.log('Co infoHash') })
    torrent.on('metadata', function() { console.log('Co metadata') })
    torrent.on('ready', function() { console.log('Co ready') })
    torrent.on('done', function() { console.log('Co done') })
    torrent.on('download', function() { console.log('Co download') })
    torrent.on('wire', function() { console.log('Co wire') })
})

Of all the torrent.on events, only the event "done" gets called and only on the client.on part of the code.

A dedicated torrent.on('seeding') and/or other events would be great to figure out when a torrent is actually starting/ready to seed.

@Tercus

This comment has been minimized.

Copy link
Contributor Author

@Tercus Tercus commented Apr 12, 2016

It seems like this is not just affecting the ones from client.seed, but also the ones from client.add. I added a torrent with client.add and tried to use the torrent.on events inside of client.on, but only the events 'done' and 'download' were called, all the others did nothing.

I edited the title

@Tercus Tercus changed the title client.seed and torrent.on events torrent.on events of client.seed and client.add Apr 12, 2016
@DiegoRBaquero

This comment has been minimized.

Copy link
Member

@DiegoRBaquero DiegoRBaquero commented Apr 12, 2016

Can only be accessed sync. Added the note here #750 and also added uploaded event.

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Apr 23, 2016

@Tercus This is what your example should look like:

var torrent = client.seed(torrentfile, { announceList: [['ws://localhost:8080']] }, onseed)

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') })
})

function onseed (torrent) {
  console.log('onseed getting called')
}
@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
3 participants
You can’t perform that action at this time.