Ejemplo n.º 1
0
        void OnReadEvent(HttpClientResponse response, long totalReadBytes)
        {
            if (totalReadBytes >= response.MaxReadBytes)
            {
                // 判断版本
                HttpClientStrResponse r = response as HttpClientStrResponse;
                string versionStr       = r.Txt;
                if (!string.IsNullOrEmpty(versionStr))
                {
                    AutoUpdateMgr.Instance.LoadServerResVer(versionStr);
                    string resVer = AutoUpdateMgr.Instance.CurrServeResrVersion;
                    if (!string.IsNullOrEmpty(resVer))
                    {
                        if (AutoUpdateMgr.Instance.IsVersionNoUpdate())
                        {
                            // CheckFileList

                            AutoUpdateMgr.Instance.EndAutoUpdate();
                        }
                        else
                        {
                            ToNextState();
                        }
                    }
                    else
                    {
                        AutoUpdateMgr.Instance.EndAutoUpdate();
                    }
                }
                else
                {
                    AutoUpdateMgr.Instance.EndAutoUpdate();
                }
            }
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
 void OnReadEvent(HttpClientResponse response, long totalReadBytes)
 {
     if (totalReadBytes >= response.MaxReadBytes)
     {
         HttpClientStrResponse r = response as HttpClientStrResponse;
         string fileList         = r.Txt;
         DoFileListTxt(fileList);
     }
 }
Ejemplo n.º 4
0
 void OnReadEvent(HttpClientResponse response, long totalReadBytes)
 {
     if (totalReadBytes >= response.MaxReadBytes)
     {
         // 判断版本
         HttpClientStrResponse r = response as HttpClientStrResponse;
         string versionStr       = r.Txt;
         DoVersionTxt(versionStr);
     }
 }
Ejemplo n.º 5
0
        internal HttpClient CreateHttpTxt(string url, Action <HttpClientResponse, long> OnReadEvt,
                                          Action <HttpClientResponse, int> OnErrorEvt)
        {
            HttpRelease();
            HttpClientStrResponse response = new HttpClientStrResponse();

            response.OnReadEvt  = OnReadEvt;
            response.OnErrorEvt = OnErrorEvt;
            m_HttpClient        = new HttpClient(url, response, m_HttpConnectTimeOut);
            return(m_HttpClient);
        }
Ejemplo n.º 6
0
        public HttpClient CreateHttpTxt(string url, Action <HttpClientResponse, long> OnReadEvt,
                                        Action <HttpClientResponse, int> OnErrorEvt)
        {
            HttpRelease();
            HttpClientStrResponse response = new HttpClientStrResponse();

            response.OnReadEvt  = OnReadEvt;
            response.OnErrorEvt = OnErrorEvt;
            m_HttpClient        = new HttpClient(url, response, 5.0f);
            return(m_HttpClient);
        }
Ejemplo n.º 7
0
        // 新的HTTP框架文本请求
        internal void CreateHttpTxt(string url, Action <HttpClient, HttpListenerStatus> onEnd, Action <HttpClient> onProcess = null)
        {
            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            HttpRelease();
            HttpClientStrResponse response = new HttpClientStrResponse(4 * 1024);

            lock (m_Lock)
            {
                m_HttpClient = HttpHelper.OpenUrl <HttpClientStrResponse>(url, response, onEnd, onProcess, m_HttpConnectTimeOut);
            }
        }
Ejemplo n.º 8
0
        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;
            }
        }
Ejemplo n.º 9
0
        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;
            }
        }
Ejemplo n.º 10
0
        void OnReadEvent(HttpClientResponse response, long totalReadBytes)
        {
            if (totalReadBytes >= response.MaxReadBytes)
            {
                HttpClientStrResponse r = response as HttpClientStrResponse;
                string fileList         = r.Txt;
                if (string.IsNullOrEmpty(fileList))
                {
                    AutoUpdateMgr.Instance.EndAutoUpdate();
                    return;
                }

                string writePath   = AutoUpdateMgr.Instance.WritePath;
                string srcFileName = string.Format("{0}/{1}", writePath, AutoUpdateMgr._cFileListTxt);
                if (!File.Exists(srcFileName))
                {
                    // 直接生成写到update.txt里
                    ResListFile resListFile = AutoUpdateMgr.Instance.ServerResListFile;
                    resListFile.Load(fileList);
                    ResListFile.ResDiffInfo[] infos = resListFile.AllToDiffInfos();

                    AutoUpdateMgr.Instance.UpdateToUpdateTxt(infos);
                    AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(infos);

                    ToNextState();
                    return;
                }

                ResListFile srcListFile = AutoUpdateMgr.Instance.LocalResListFile;
                ResListFile dstListFile = AutoUpdateMgr.Instance.ServerResListFile;

                dstListFile.Load(fileList);

                ResListFile.ResDiffInfo[] diffInfos = srcListFile.GetDiffInfos(dstListFile);

                AutoUpdateMgr.Instance.UpdateToUpdateTxt(diffInfos);
                AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(diffInfos);
                ToNextState();
            }
        }
        void OnReadEvent(HttpClientResponse response, long totalReadBytes)
        {
            if (totalReadBytes >= response.MaxReadBytes)
            {
                HttpClientStrResponse r = response as HttpClientStrResponse;
                string zipVerList       = r.Txt;
                if (string.IsNullOrEmpty(zipVerList))
                {
                    AutoUpdateMgr.Instance.CurrUpdateZipFileMd5 = string.Empty;
                    ToNextStatus();
                    return;
                }

                string oldVer      = AutoUpdateMgr.Instance.LocalResVersion;
                string newVer      = AutoUpdateMgr.Instance.CurrServeResrVersion;
                string zipFileName = ZipTools.GetZipFileName(oldVer, newVer);

                ResListFile zipFiles = new ResListFile();
                zipFiles.Load(zipVerList);

                ResListFile.ResDiffInfo[] diff;
                if (!zipFiles.FileToDiffInfo(zipFileName, out diff) || diff == null ||
                    string.IsNullOrEmpty(diff[0].fileContentMd5) ||
                    diff[0].fileSize <= 0)
                {
                    AutoUpdateMgr.Instance.CurrUpdateZipFileMd5 = string.Empty;
                    ToNextStatus();
                    return;
                }

                AutoUpdateMgr.Instance.UpdateToUpdateTxt(diff);
                AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(diff);
                AutoUpdateMgr.Instance.CurrUpdateZipFileMd5 = diff[0].fileContentMd5;
                ToNextStatus();
            }
        }