demo.lua

changeset 2
38f221e53215
parent 1
7ef4b95f77b5
equal deleted inserted replaced
1:7ef4b95f77b5 2:38f221e53215
11 end 11 end
12 print("---------------"); 12 print("---------------");
13 end 13 end
14 14
15 local function progresscallback(batch) 15 local function progresscallback(batch)
16 for url,progress in pairs(batch:progress()) do 16 print("Progress:");
17 for url, progress in pairs(batch:progress()) do
17 print(url..":"); 18 print(url..":");
18 for statistic, value in pairs(progress) do 19 for statistic, value in pairs(progress) do
19 print("", k..": "..v); 20 print("", statistic..": "..value);
20 end 21 end
21 end 22 end
22 print(""); 23 print("");
23 end 24 end
24 25
25 batch_download = multihttp.new(mycallback, { "http://www.google.com/", "http://example.com/" }); 26 batch_download = multihttp.new(mycallback, { "http://www.google.com/", "http://example.com/" });
26 27
27 batch_download:set_progress_callback(progresscallback); 28 batch_download:set_progress_callback(progresscallback, 1); -- Call progresscallback every second
28 29
29 batch_download:download(true); -- true means "don't return until all downloads are finished" 30 batch_download:download(true); -- true means "don't return until all downloads are finished"

mercurial