@@ -45,21 +45,26 @@ WebSocketTracker.prototype.announce = function (opts) {
4545 return self . socket . once ( 'connect' , self . announce . bind ( self , opts ) )
4646 }
4747
48- // Limit the number of offers that are generated, since it can be slow
49- var numwant = Math . min ( opts . numwant , 10 )
50-
51- self . _generateOffers ( numwant , function ( offers ) {
52- var params = extend ( opts , {
53- action : 'announce' ,
54- numwant : numwant ,
55- info_hash : self . client . _infoHashBinary ,
56- peer_id : self . client . _peerIdBinary ,
57- offers : offers
58- } )
59- if ( self . _trackerId ) params . trackerid = self . _trackerId
48+ var params = extend ( opts , {
49+ action : 'announce' ,
50+ info_hash : self . client . _infoHashBinary ,
51+ peer_id : self . client . _peerIdBinary
52+ } )
53+ if ( self . _trackerId ) params . trackerid = self . _trackerId
6054
55+ if ( opts . event === 'stopped' ) {
56+ // Don't include offers with 'stopped' event
6157 self . _send ( params )
62- } )
58+ } else {
59+ // Limit the number of offers that are generated, since it can be slow
60+ var numwant = Math . min ( opts . numwant , 10 )
61+
62+ self . _generateOffers ( numwant , function ( offers ) {
63+ params . numwant = numwant
64+ params . offers = offers
65+ self . _send ( params )
66+ } )
67+ }
6368}
6469
6570WebSocketTracker . prototype . scrape = function ( opts ) {
@@ -337,6 +342,7 @@ WebSocketTracker.prototype._generateOffers = function (numwant, cb) {
337342 for ( var i = 0 ; i < numwant ; ++ i ) {
338343 generateOffer ( )
339344 }
345+ checkDone ( )
340346
341347 function generateOffer ( ) {
342348 var offerId = hat ( 160 )
0 commit comments