/// <summary> /// 下载失败 /// </summary> void OnFailed(emErrorCode code) { lock (lock_obj_) { if (content_ != null) { content_.State = DownloadContent.emState.Failed; content_.Close(); content_ = null; } if (http_request_ != null) { http_request_.Abort(); http_request_ = null; } IsDone = true; ErrorCode = code; if (error_callback_ != null) { error_callback_(this); } } }
/// <summary> /// 提供外部调用下载开始接口函数 /// </summary> public void Start(string root, string localname, Action <HttpAsyDownload, long> notify = null, Action <HttpAsyDownload> error = null) { lock (lock_object) { //TODO 不知道为什么要先终止下载 //下载之前先终止 Root = root; LocalName = localname; if (notify != null) { notify_callback = notify; } if (error != null) { error_callback = error; } //设置各种属性的初始值 IsDone = false; ErrorCode = emErrorCode.None; Content = new DownloadContent(FullName); CompletedLength = 0; Length = 0; //开始下载 } }
/// <summary> /// 错误 /// </summary> void Error(emErrorCode ec, string message = null) { ErrorCode = ec; string ms = string.IsNullOrEmpty(message) ? ErrorCode.ToString() : ErrorCode.ToString() + " - " + message; Debug.LogError(ms); }
/// <summary> /// /// </summary> void Error(emErrorCode ec, string message = null) { lock (lock_obj_) { string ms = string.IsNullOrEmpty(message) ? ec.ToString() : ec.ToString() + " - " + message; Debug.LogError(ms); ErrorCode = ec; IsDone = true; Abort(); } }
/// <summary> /// /// </summary> void Error(emErrorCode ec, string message = null) { ErrorCode = ec; StringBuilder sb = new StringBuilder("[AssetBundleError] - "); sb.Append(ErrorCode.ToString()); if (!string.IsNullOrEmpty(message)) { sb.Append("\n"); sb.Append(message); } Debug.LogWarning(sb.ToString()); }
/// <summary> /// 开始下载 /// </summary> public void Start(string root, string local_file_name , Action <HttpAsyDownload, long> notify = null , Action <HttpAsyDownload> error_cb = null) { lock (lock_obj_) { Abort(); Root = root; LocalName = local_file_name; IsDone = false; ErrorCode = emErrorCode.None; notify_callback_ = notify; error_callback_ = error_cb; content_ = new DownloadContent(FullName, false); CompletedLength = 0; Length = 0; _Download(); } }
private void OnFailed(emErrorCode code) { lock (lock_object) { if (Content != null) { Content.State = DownloadContent.emState.Failed; Content.Close(); Content = null; } if (_httpWebRequest != null) { _httpWebRequest.Abort(); _httpWebRequest = null; } if (error_callback != null) { error_callback(this); } } }