Ejemplo n.º 1
0
        public EZWWWTask Download(string relativePath)
        {
            if (!updateMode)
            {
                return(null);
            }
            relativePath = relativePath.ToLower();
            string    source    = serverAddress + relativePath;
            string    localPath = runtimeDirPath + relativePath;
            EZWWWTask task      = EZNetwork.Instance.NewTask(source, null);

            task.onStopEvent += delegate(string url, byte[] bytes)
            {
                if (bytes != null)
                {
                    downloadList.Add(url);
                    File.WriteAllBytes(localPath, bytes);
                    Log("Task complete -> " + url);
                }
                else
                {
                    Log("Task failed -> " + url);
                }
            };
            return(task);
        }
Ejemplo n.º 2
0
        private void NextTask()
        {
            if (taskQueue.Count <= 0)
            {
                return;
            }
            EZWWWTask task = taskDict[taskQueue.Dequeue()];

            taskList.Add(task.url);
            task.StartTask();
        }
Ejemplo n.º 3
0
        public EZWWWTask NewTask(string url, byte[] postData)
        {
            EZWWWTask task = gameObject.AddComponent <EZWWWTask>();

            task.SetTask(url, postData);
            task.onStopEvent += OnComplete;
            if (taskList.Count >= maxTask)
            {
                taskQueue.Enqueue(url);
                taskDict.Add(url, task);
            }
            else
            {
                taskList.Add(url);
                taskDict.Add(url, task);
                task.StartTask();
            }
            return(task);
        }