Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在进程之后回调函数_Javascript_Node.js_Asynchronous_Bittorrent - Fatal编程技术网

Javascript 在进程之后回调函数

Javascript 在进程之后回调函数,javascript,node.js,asynchronous,bittorrent,Javascript,Node.js,Asynchronous,Bittorrent,我使用bittorent tracker软件包获取给定torrent的播种机和播种机的数量,但无法知道torrent刮削过程是否在客户端终止。例如,on('scrape_terminated')。。。是否有办法检测刮削是否终止 var Tracker = require('bittorrent-tracker') var magnet = require('magnet-uri') var magnetURI = "magnet:?xt=urn:btih:7a0e02e22744ddb80748

我使用bittorent tracker软件包获取给定torrent的播种机和播种机的数量,但无法知道torrent刮削过程是否在客户端终止。例如,on('scrape_terminated')。。。是否有办法检测刮削是否终止

var Tracker = require('bittorrent-tracker')
var magnet = require('magnet-uri')
var magnetURI = "magnet:?xt=urn:btih:7a0e02e22744ddb807480f580cc328925d5810d4&dn=Terminator+2%3A+Judgment+Day+DC+%281991%29+1080p+BrRip+x264+-+YIFY&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969"

var parsedTorrent = magnet(magnetURI)

var opts = {
infoHash: parsedTorrent.infoHash,
announce: parsedTorrent.announce,
peerId: new Buffer('01234567890123456789'), // hex string or Buffer
port: 6881 // torrent client port
}

var client = new Tracker(opts)

client.scrape();

client.on('scrape', function (data) {
 console.log('number of seeders in the swarm: ' + data.complete)
 console.log('number of leechers in the swarm: ' + data.incomplete)
});

client.on('error',function(data) {
 console.log('erreur');
})

当调用client.on('scrape')…函数时,是否意味着报废已完成?否,因为如果没有“scrape terminated”,则可以多次调用此函数事件,可能这不是它的工作方式。可能它会表现为一个错误,或一个常规的刮取事件…可能最好首先询问制作该模块的人员。此外,“在进程后回调函数”并不能准确描述您正在讨论的问题。不,没有刮取终止事件