private void OnHttpsCallBack(HttpClient https, HttpListenerStatus status) { m_Https = null; switch (status) { case HttpListenerStatus.hsError: ApkUpdateMonitor.GetInstance().OnError(this.Id, ApkUpdateError.Get_Server_Version_Error); break; case HttpListenerStatus.hsDone: var rep = https.Listener as HttpClientStrResponse; if (rep != null) { string str = rep.Txt; bool isOk = ApkUpdateMonitor.GetInstance().LoadCurApkVer(str); if (!isOk) { ApkUpdateMonitor.GetInstance().OnError(this.Id, ApkUpdateError.Get_Server_Version_Error); return; } // 处理吧,这个获得成功 OnCheckVersion(); } else { ApkUpdateMonitor.GetInstance().OnError(this.Id, ApkUpdateError.Get_Server_Version_Error); } break; default: ApkUpdateMonitor.GetInstance().OnError(this.Id, ApkUpdateError.Get_Server_Version_Error); break; } }
private void OnHttpEnd(HttpClient client, HttpListenerStatus status) { m_Https = null; switch (status) { case HttpListenerStatus.hsError: ApkUpdateMonitor.GetInstance().OnError(ApkUpdateState.CheckApkDiff, ApkUpdateError.Get_Server_ApkDiff_Error); break; case HttpListenerStatus.hsDone: HttpClientStrResponse rep = client.Listener as HttpClientStrResponse; if (rep != null) { bool ret = ApkUpdateMonitor.GetInstance().LoadApkDiff(rep.Txt); if (!ret) { ApkUpdateMonitor.GetInstance().OnError(ApkUpdateState.CheckApkDiff, ApkUpdateError.Get_Server_ApkDiff_Error); return; } // 更新完了 OnCheckApkDiff(); } else { ApkUpdateMonitor.GetInstance().OnError(ApkUpdateState.CheckApkDiff, ApkUpdateError.Get_Server_ApkDiff_Error); } break; default: ApkUpdateMonitor.GetInstance().OnError(ApkUpdateState.CheckApkDiff, ApkUpdateError.Get_Server_ApkDiff_Error); break; } }
// 读取完成 public void OnEnd() { DownProcess = 1.0f; End(); if (OnEndEvt != null) OnEndEvt(this); Status = HttpListenerStatus.hsDone; }
public virtual void OnError(int status) { Status = HttpListenerStatus.hsError; if (OnErrorEvt != null) { OnErrorEvt(this, status); } DoClose(); }
public void OnResponse(HttpWebResponse rep, HttpClient client) { if (rep == null) { OnError(-1); return; } /* * if (rep.StatusCode == HttpStatusCode.PartialContent) * m_Rep = rep; * else*/ m_Rep = rep; m_Client = client; try { Status = HttpListenerStatus.hsDoing; m_OrgStream = rep.GetResponseStream(); if (m_OrgStream == null) { OnError(-1); return; } if (m_OrgStream.CanTimeout) { m_OrgStream.ReadTimeout = _cReadTimeOut; } System.Threading.Interlocked.Exchange(ref m_MaxReadBytes, rep.ContentLength); //m_MaxReadBytes = rep.ContentLength; if (m_MaxReadBytes == -1) { // 有些页面会返回-1,ContentLength会忽略 // 但客户端需要最大长度否则有问题 } else if (m_MaxReadBytes <= 0) { OnEnd(); DoClose(); return; } // UnityEngine.Debug.Log("OnResponse"); m_OrgStream.BeginRead(m_Buf, 0, m_Buf.Length, m_ReadCallBack, this); // don't m_OrgStream.Close } catch { OnError(-1); } }
// 新的回调下载接口(都是主线程) void OnHttpEnd(HttpClient client, HttpListenerStatus status) { switch (status) { case HttpListenerStatus.hsDone: { StartNextDownload(); break; } case HttpListenerStatus.hsError: { DebugFileError(); AutoUpdateMgr.Instance.Error(AutoUpdateErrorType.auError_FileDown, -1); break; } } }
void OnEnd(HttpClient client, HttpListenerStatus status) { switch (status) { case HttpListenerStatus.hsDone: { HttpClientStrResponse r = client.Listener as HttpClientStrResponse; string fileList = r.Txt; DoFileListTxt(fileList); break; } case HttpListenerStatus.hsError: AutoUpdateMgr.Instance.Error(AutoUpdateErrorType.auError_NoGetFileList, -1); break; } }
void OnEnd(HttpClient client, HttpListenerStatus status) { switch (status) { case HttpListenerStatus.hsDone: { HttpClientStrResponse r = client.Listener as HttpClientStrResponse; string versionStr = r.Txt; DoVersionTxt(versionStr); break; } case HttpListenerStatus.hsError: AutoUpdateMgr.Instance.Error(AutoUpdateErrorType.auError_NoGetVersion, -1); break; } }
void OnItemHttpEnd(HttpClient client, HttpListenerStatus status) { DonwloadItem downItem = null; var listener = client.Listener as HttpClientFileStream; if (listener != null && listener.UserData != null) { downItem = listener.UserData as DonwloadItem; listener.UserData = null; } switch (status) { case HttpListenerStatus.hsDone: { if (downItem != null) { downItem.SetNull(); } if (IsAllHttpDone()) { ToNextState(); } break; } case HttpListenerStatus.hsError: { if (downItem != null) { downItem.SetNull(); ClearList(); UnityEngine.Debug.LogErrorFormat("[downloadFileErr]{0} download: {1:D} isOk: {2}", downItem.item.fileContentMd5, downItem.item.readBytes, downItem.item.isDone.ToString()); AutoUpdateMgr.Instance.Error(AutoUpdateErrorType.auError_FileDown, -1); m_IsError = true; } break; } } }
void OnDownEnd(HttpClient client, HttpListenerStatus status) { switch (status) { case HttpListenerStatus.hsDone: { process = 1f; Debug.Log("下载完成"); break; } case HttpListenerStatus.hsError: { Debug.Log("下载失败"); break; } } m_Client = null; }
private void OnHttpEnd(HttpClient client, HttpListenerStatus status) { m_Http = null; var target = ApkUpdateMonitor.GetInstance(); switch (status) { case HttpListenerStatus.hsError: target.OnError(ApkUpdateState.CheckLocalNewZip, ApkUpdateError.Get_Server_DiffZip_Down_Error); break; case HttpListenerStatus.hsDone: target.ChangeState(ApkUpdateState.CombiningNewApk); break; default: target.OnError(ApkUpdateState.CheckLocalNewZip, ApkUpdateError.Get_Server_DiffZip_Down_Error); break; } }
public void OnResponse(HttpWebResponse rep) { if (rep == null) { OnError(-1); return; } /* * if (rep.StatusCode == HttpStatusCode.PartialContent) * m_Rep = rep; * else*/ m_Rep = rep; m_OrgStream = rep.GetResponseStream(); if (m_OrgStream == null) { OnError(-1); return; } if (m_OrgStream.CanTimeout) { m_OrgStream.ReadTimeout = _cReadTimeOut; } m_MaxReadBytes = rep.ContentLength; if (m_MaxReadBytes <= 0) { OnEnd(); DoClose(); return; } Status = HttpListenerStatus.hsDoing; // UnityEngine.Debug.Log("OnResponse"); m_OrgStream.BeginRead(m_Buf, 0, m_Buf.Length, m_ReadCallBack, this); // don't m_OrgStream.Close }
void OnHttpEnd(HttpClient client, HttpListenerStatus status) { if (status == HttpListenerStatus.hsDone) { // 已经读完 ClearTex(); HttpClientPicResponse pic = client.Listener as HttpClientPicResponse; if (pic != null) { m_Tex = pic.GeneratorTexture(); UITexture t = GetComponent <UITexture>(); if (t != null) { t.mainTexture = m_Tex; if (m_Tex != null) { t.width = m_Tex.width; t.height = m_Tex.height; } } } } }