我想为firefox开发一个插件,将进度事件发送到套接字服务器, 以下代码属于我在插件中的javascript:
onProgressChange: function( aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress, aDownload){
// alert("1: "+aWebProgress+" 2: "+aRequest+" 3: "+aCurSelfProgress+" 4: "+aMaxSelfProgress+" 5: "+aCurTotalProgress+" 6: "+aMaxTotalProgress+" 7: "+aDownload);
var transport = Components.classes["@mozilla.org/network/socket-transport-service;1"]
.getService(Components.interfaces.nsISocketTransportService)
.createTransport(null, 0, "127.0.0.1", 23456, null);
var stream = transport.openOutputStream(0, 0, 0);
var data = "ProgressChange;"+String(aCurSelfProgress)+";"+String(aMaxSelfProgress)+";"+String(aCurTotalProgress)+";"+String(aMaxTotalProgress)+";"+String(aDownload.id)+";"+String(aDownload.state)+";"+String(aDownload.displayName);
stream.write(data, data.length);
stream.close();
}
存在以下问题:
aCurSelfProgress和aCurTotalProgress始终具有相同的值,它与正在运行的下载量无关。
在我看来,aCurTotalProgress必须是每次下载的每个aCurTotalProgress的总和,但事实并非如此。无法识别多个下载...
我是否误解了参考文献: nsIDownloadProgressListener
有任何帮助或提示吗?