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

Notify caller of torrent creation in seed call #1696

Closed
wants to merge 2 commits into from

Conversation

@ddumont
Copy link
Contributor

ddumont commented Aug 8, 2019

onseed gets called a bit after the actual torrent file is parsed and complete. I have a progress bar for the torrent creation but there's an indeterminate amount of time between onTorrent and onSeed.

@request-info

This comment has been minimized.

Copy link

request-info bot commented Aug 8, 2019

👋 We would appreciate it if you could provide us with more information about this issue.

@feross

This comment has been minimized.

Copy link
Member

feross commented Aug 8, 2019

You can already listen to the 'torrent' event on the client.

client.seed(...)
client.on('torrent', torrent => {
})

Is that not sufficient for you?

@ddumont

This comment has been minimized.

Copy link
Contributor Author

ddumont commented Aug 9, 2019

@guanzo

This comment has been minimized.

Copy link
Contributor

guanzo commented Aug 9, 2019

client.seed() returns a torrent, can you not use that?

@ddumont

This comment has been minimized.

Copy link
Contributor Author

ddumont commented Aug 9, 2019

@guanzo

This comment has been minimized.

Copy link
Contributor

guanzo commented Aug 9, 2019

It calls a callback function after it's started seeding, but it also returns a torrent. You can attach listeners to the returned torrent, which is accessible even before the onTorrent callback is called. Or am I misunderstanding something?

const torrent = client.seed(torrentId)
torrent.on('') // listen for events
@ddumont

This comment has been minimized.

Copy link
Contributor Author

ddumont commented Aug 9, 2019

@guanzo

This comment has been minimized.

Copy link
Contributor

guanzo commented Aug 9, 2019

I don't understand why you can't just do this.

const torrent = client.seed(input)
torrent.once('ready', () => {
    // ontorrent was called
})

The ready event listener is called when ontorrent is called. It achieves the same effect as your pull request. The ontorrent callback is called here:

https://github.com/ddumont/webtorrent/blob/b335b0aa710d8823257e53bcf0baef38b9176278/index.js#L222-L225

The torrent emits a ready event that triggers the call to ontorrent, which you can capture using the above example.

@ddumont

This comment has been minimized.

Copy link
Contributor Author

ddumont commented Aug 9, 2019

@guanzo

This comment has been minimized.

Copy link
Contributor

guanzo commented Aug 9, 2019

client.seed returns a torrent.

@ddumont

This comment has been minimized.

Copy link
Contributor Author

ddumont commented Aug 11, 2019

yes that works, I did not realize it returned the torrent

@ddumont ddumont closed this Aug 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.