public DownloadTask DownLoadBundles(string[] bundlePaths, Action <object> downloadCall, Action <Resource, int, int> downloadPerCall, object userData, Action <Resource> beginCall, Action <string, string> failCall, ushort priority = DEFAULT_PRIORITY) { DownloadTask task = ObjectPool.GetObject <DownloadTask>(); task.InitTask(bundlePaths, FinishDownLoadTask, downloadCall, downloadPerCall, userData, beginCall, failCall, priority); if (task.HasDownload()) { addDownLoadTask(task); } return(task); }
public DownloadTask DownLoadBundles(string[] bundlePaths, Action <object> downloadCall, object userData, ushort priority) { DownloadTask task = ObjectPool.GetObject <DownloadTask>(); task.InitTask(bundlePaths, FinishDownLoadTask, downloadCall, null, userData, null, null, priority); if (task.HasDownload()) { addDownLoadTask(task); } return(task); }
public DownloadTask DownLoadBundles(string[] bundlePaths, Action <object> downloadCall, ushort priority, Action <Resource, int, int> downPerAsset = null) { DownloadTask task = ObjectPool.GetObject <DownloadTask>(); task.InitTask(bundlePaths, FinishDownLoadTask, downloadCall, downPerAsset, null, null, null, priority); if (task.HasDownload()) { addDownLoadTask(task); } return(task); }
private void Process() { mLog.Info("Download process start,url:[{0}],filename;[{0}]", this.mUrl, this.mFilename); DownloadTask task = new DownloadTask(); task.RemotePath = this.mUrl; task.LocalPath = this.mFilename; task.BlockSize = 1024 * 1024 * 3; if (task.InitTask()) { this.ThreadDownload(task); } }
static void Main(string[] args) { DownloadTask task = new DownloadTask(); task.RemotePath = @"http://speed.myzone.cn/pc_elive_1.1.rar"; task.LocalPath = @"d:\hehe.rar"; task.BlockSize = 1024 * 1024 * 3; if (task.InitTask()) { Console.WriteLine("begin download"); Program p = new Program(); p.ThreadDownload(task); } Console.ReadKey(); }
public void OnCreateTask() { var task = new DownloadTaskInfo(); GlobalMessageCenter.Instance.Send("CreateDownloadTask", task); if (task.IsValid) { var filesize = HttpDownload.HttpFileSplit.TryGetContentLength(task.RemotePath); if (filesize <= 0) { GlobalMessageCenter.Instance.Send("TaskError.Size"); return; } var blockSize = (filesize + 224) / 225; var downloadTask = new DownloadTask() { RemotePath = task.RemotePath, LocalPath = task.LocalPath, CfgPath = task.LocalPath + ".cfg", BlockSize = blockSize, }; if (downloadTask.InitTask()) { CurrentTask = downloadTask; CurrentRemotePath = CurrentTask.RemotePath; } ClearProgress(); if (task.IsEnableDistributed) { foreach (var info in PeerInfoList) { var peer = PeerInfo2Peer(info); var subtask = CurrentTask.GetSubTask(); InstPeer(peer, subtask, blockSize); if (subTask_[peer.EndPoint.ToString()] != null) { FileBlockTask f = new FileBlockTask(subTask_[peer.EndPoint.ToString()]); master.Send(peer, f.Encode()); } } } } }
static void Main(string[] args) { task = new DownloadTask(); task.RemotePath = @"http://speed.myzone.cn/pc_elive_1.1.rar"; //60M //task.RemotePath = @"http://cd002.www.duba.net/duba/install/2011/ever/duba160406_100_50.exe"; //17M task.LocalPath = @"d:\hehe.rar"; task.BlockSize = 1024 * 1024 * 3; if (task.InitTask()) { Console.WriteLine("begin download"); } Console.ReadKey(); master = new MasterPeer(); master.Start(IPAddress.Any, 48360, new MasterPeerListener()); List <KeyValuePair <string, int> > peerList = new List <KeyValuePair <string, int> >() { new KeyValuePair <string, int>("127.0.0.1", 48360), //new KeyValuePair<string, int>("10.20.208.27", 48235), //new KeyValuePair<string, int>("10.20.208.27", 48362), //new KeyValuePair<string, int>("10.20.221.119", 48360), //new KeyValuePair<string, int>("10.20.208.30", 48360), //wyf //new KeyValuePair<string, int>("10.20.208.38", 48390), //hym //new KeyValuePair<string, int>("10.20.208.55", 48390), //hsj }; foreach (var i in peerList) { var peer = new Peer() { EndPoint = new IPEndPoint(IPAddress.Parse(i.Key), i.Value) }; master.Connect(peer); } Console.ReadKey(); }