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 upNotify caller of torrent creation in seed call #1696
Conversation
This comment has been minimized.
This comment has been minimized.
request-info
bot
commented
Aug 8, 2019
This comment has been minimized.
This comment has been minimized.
|
You can already listen to the client.seed(...)
client.on('torrent', torrent => {
})Is that not sufficient for you? |
This comment has been minimized.
This comment has been minimized.
|
It wasn't working well with react. Plus, I don't want to listen for all
torrents, I just want to watch for this one. I lose state of the seed call
if I use the global one.
…Sent from my Pixel XL
On Thu, Aug 8, 2019, 6:25 PM Feross Aboukhadijeh ***@***.***> wrote:
You can already listen to the 'torrent' event on the client.
client.seed(...)client.on('torrent', torrent => {
})
Is that not sufficient for you?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1696?email_source=notifications&email_token=AADV3LRF7YSEW6D4YIXTSGLQDSMMXA5CNFSM4IKOWIF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD35CE7I#issuecomment-519709309>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADV3LUC4QSRMPHTZ5D5WX3QDSMMXANCNFSM4IKOWIFQ>
.
On Thu, Aug 8, 2019, 6:25 PM Feross Aboukhadijeh ***@***.***> wrote:
You can already listen to the 'torrent' event on the client.
client.seed(...)client.on('torrent', torrent => {
})
Is that not sufficient for you?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1696?email_source=notifications&email_token=AADV3LRF7YSEW6D4YIXTSGLQDSMMXA5CNFSM4IKOWIF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD35CE7I#issuecomment-519709309>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADV3LUC4QSRMPHTZ5D5WX3QDSMMXANCNFSM4IKOWIFQ>
.
|
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
It returns a torrent after it's started seeding. I have a progress bar for
the torrent creation. I gave create torrent the ability to callback with
progress. Without adding the torrent immediately, there's a weird delay at
100% because it has to start serving before it calls the callback.
…Sent from my Pixel XL
On Thu, Aug 8, 2019, 10:12 PM Eric Guan ***@***.***> wrote:
client.seed() returns a torrent, can you not use that?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1696?email_source=notifications&email_token=AADV3LWAC6FLLDIJOOOTOGLQDTHA7A5CNFSM4IKOWIF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD35MJWQ#issuecomment-519750874>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADV3LX3R6IPJCP3CT2UFE3QDTHA7ANCNFSM4IKOWIFQ>
.
|
This comment has been minimized.
This comment has been minimized.
|
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 const torrent = client.seed(torrentId)
torrent.on('') // listen for events |
This comment has been minimized.
This comment has been minimized.
|
I think you are, sorry. I'm probably not explaining it well.
client.seed will do a few things. If you pass it a file, it will create a
torrent. This takes some time, depending on the size of the file.
After the torrent is created, it will start seeding. After the torrent is
seeding, it will call the onseed callback.
I just wanted to get a callback for when the torrent was done so that I
could have the UI be a bit more responsive.
…On Thu, Aug 8, 2019 at 10:27 PM Eric Guan ***@***.***> wrote:
It calls a callback function after it's started seeding, which is
different than the return value. 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
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1696?email_source=notifications&email_token=AADV3LVPW6KAIRZ4C7N5QY3QDTIXXA5CNFSM4IKOWIF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD35M57I#issuecomment-519753469>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADV3LT5UHKC6T3PGXEWJTDQDTIXXANCNFSM4IKOWIFQ>
.
|
This comment has been minimized.
This comment has been minimized.
|
I don't understand why you can't just do this. const torrent = client.seed(input)
torrent.once('ready', () => {
// ontorrent was called
})The The torrent emits a |
This comment has been minimized.
This comment has been minimized.
|
Because I'm calling seed with a list of files, I don't have a torrent yet
…Sent from my Pixel XL
On Thu, Aug 8, 2019, 10:50 PM Eric Guan ***@***.***> wrote:
I don't understand why you can't just do this.
const torrent = client.seed(torrentId)torrent.once('ready', () => {
// ontorrent was called
})
The 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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1696?email_source=notifications&email_token=AADV3LR3FCQ2ABIHR4UTPCLQDTLOZA5CNFSM4IKOWIF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD35N34Q#issuecomment-519757298>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADV3LUXICQBMTKRJ5W2I4LQDTLOZANCNFSM4IKOWIFQ>
.
|
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
yes that works, I did not realize it returned the torrent |

ddumont commentedAug 8, 2019
•
edited
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.