V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
123s
V2EX  ›  Node.js

aria2 库下载问题

  •  
  •   123s · 2017-03-17 16:50:56 +08:00 · 1716 次点击
    这是一个创建于 2568 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我做了一个小玩具,在 vps 上做一个下载中转的。 nodejs 连接 rpc ,然后用的是 aria2 这个库。问题就是它会产生多次的(每次加1个) onDownloadCompelte 事件。

    Download.prototype.init = function() {
        aria2 = new Aria2({
            host: 'localhost',
            port: 6800,
            secure: false,
            secret: '',
            path: '/jsonrpc'
        });
        
        _onDownloadStart();
        _onDownloadComplete();
    }
    
    Download.prototype.dl = fn;
    
    
    ....
    
    var Down = new Download();
    
    ....很多行
    
    if(method== 'post') {
       Down.dl()
    }
    
    

    每次路由就调一次 Down.dl 方法,产生一次 start 和 Complete ,但不知道为什么从第二次下载开始就会触发多次的 start 和 complete 。我看了 arai2 这个 npm 包,它没有实现这 2 个事件,貌似是由 rpc 这个对象返回的,那是 arai2 程序本身的问题?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4091 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:19 · PVG 13:19 · LAX 22:19 · JFK 01:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.