/// <summary>
        /// 调用方法
        /// </summary>
        void OnExtractFile(List <object> evParams)
        {
            ///------------------通知更新面板解压完成--------------------
            NotiData data = new NotiData(MessageTypes.UPDATE_EXTRACT, null);

            SyncEvent?.Invoke(data);
        }
        private void DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            Debug.Log("下载完成");
            NotiData data = new NotiData(MessageTypes.UPDATE_DOWNLOAD, currDownFile);

            SyncEvent?.Invoke(data);
        }
Example #3
0
    /// <summary>
    /// 线程完成
    /// </summary>
    /// <param name="data"></param>
    void OnThreadCompleted(NotiData data)
    {
        switch (data.evName)
        {
        case NotiConst.UPDATE_EXTRACT:      //解压一个完成

            break;

        case NotiConst.UPDATE_DOWNLOAD:     //下载一个完成
            downloadFiles.Add(data.evParam.ToString());
            allreadyUpdate++;
            Debug.Log("资源更新完成:" + data.evParam.ToString());
            break;

        case NotiConst.UPDATE_Speed:     //下载进度

            Loom.InvokeSync(() =>
            {
                //text.text = string.Format("正在下载最新资源... ({0}/{1}))       {2}", allreadyUpdate.ToString(), needUpdateCount.ToString(), data.evParam.ToString());
            });
            break;

        case NotiConst.UPDATE_Progress:
            //Loom.QueueOnMainThread(() =>
            //{
            //    //slider.value = (float.Parse(data.evParam.ToString())/100);
            //    //Debug.Log(float.Parse(data.evParam.ToString()) / 100);
            //});
            break;
        }
    }
Example #4
0
    private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        float    value    = (float)e.ProgressPercentage / 100f;
        string   fileName = Path.GetFileNameWithoutExtension(currDownFile);
        string   Tips     = string.Format(fileName + " {0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));
        NotiData pData    = new NotiData(NotiConst.UPDATE_PROGRESS, value);

        if (m_SyncEvent != null)
        {
            m_SyncEvent(pData);
        }

        pData = new NotiData(NotiConst.UPDATE_MESSAGE, Tips);
        if (m_SyncEvent != null)
        {
            m_SyncEvent(pData);
        }


        if (e.ProgressPercentage == 100 && e.BytesReceived == e.TotalBytesToReceive)
        {
            sw.Reset();
            pData = new NotiData(NotiConst.UPDATE_DOWNLOAD, currDownFile);
            if (m_SyncEvent != null)
            {
                m_SyncEvent(pData);
            }
        }
    }
Example #5
0
 // Update is called once per frame
 void OnUpdate()
 {
     while (true)
     {
         lock (m_lockObj)
         {
             if (events.Count > 0)
             {
                 NotiData e = events.Dequeue();
                 try {
                     switch (e.id)
                     {
                     case MessageId.DOWNLOAD_CONFIG:
                     {         //解压文件
                         OnDownloadConfig((string)e.evParams);
                     }
                     break;
                     }
                 }
                 catch (System.Exception ex)
                 {
                     UnityEngine.Debug.LogError(ex.Message);
                 }
             }
         }
         Thread.Sleep(1);
     }
 }
Example #6
0
 public void Call(NotiData param0)
 {
     func.BeginPCall();
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
Example #7
0
    private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        //UnityEngine.Debug.Log(e.ProgressPercentage);

        /*
         * UnityEngine.Debug.Log(string.Format("{0} MB's / {1} MB's",
         *  (e.BytesReceived / 1024d / 1024d).ToString("0.00"),
         *  (e.TotalBytesToReceive / 1024d / 1024d).ToString("0.00")));
         */
        //float value = (float)e.ProgressPercentage / 100f;

        string value = string.Format("{0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));

        Debug.Log(value);
        NotiData data = new NotiData(MessagesType.UPDATE_PROGRESS, value);

        if (SyncEvent != null)
        {
            SyncEvent(data);
        }

        if (e.ProgressPercentage == 100 && e.BytesReceived == e.TotalBytesToReceive)
        {
            sw.Reset();

            data = new NotiData(MessagesType.UPDATE_DOWNLOAD, currDownFile);
            if (SyncEvent != null)
            {
                SyncEvent(data);
            }
        }
    }
Example #8
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="data"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null)
     {
         func(data);
     }
 }
Example #9
0
    /// <summary>
    /// 开始解压缩
    /// </summary>
    /// <param name="localFilePath"></param>
    /// <param name="buffer"></param>
    private void BeginDecompressExtract(string localFilePath, byte[] buffer)
    {
        try
        {
            using (var decompressor = new ZstdNet.Decompressor())
            {
                var path  = localFilePath;
                var bytes = decompressor.Unwrap(buffer);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                File.WriteAllBytes(path, bytes);

                //下载文件中的MD5=未压缩时文件的MD5
                DownloadFileMD5 = MD5.ComputeHashString(bytes);
            }
        }
        catch (Exception e)
        {
            NotiData data = new NotiData(NotiConst.DOWNLOAD_EXTRACT_FAILED, this.FileName, e.Message);
            if (File.Exists(localFilePath))
            {
                File.Delete(localFilePath);
            }
            if (OnComplete != null)
            {
                OnComplete(data);                      //回调逻辑层
            }
        }
    }
Example #10
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (null != this._callback)
     {
         _callback(data);
     }
     //通知View层
 }
Example #11
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null)
     {
         func(data);                                                          //回调逻辑层
     }
     NotificationCenter.Instance.SendNotification(data.evName, data.evParam); //通知View层
 }
Example #12
0
 /// <summary>
 /// 添加到事件队列
 /// </summary>
 public void AddEvent(NotiData ev, Action <NotiData> callback)
 {
     lock (m_lockObj)
     {
         _callback = callback;
         events.Enqueue(ev);
     }
 }
Example #13
0
 public void CallWithSelf(NotiData param0)
 {
     func.BeginPCall();
     func.Push(self);
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
Example #14
0
 private void OnSyncEvent(NotiData data)
 {
     if (mFunc != null)
     {
         mFunc(data);                                            //回调逻辑层
     }
     GameFacade.SendMessageCommand(data.mEvName, data.mEvParam); //通知View层
 }
Example #15
0
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null)
     {
         this.func(data);
     }
     base.facade.SendMessageCommand(data.evName, data.evParam);
 }
Example #16
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null)
     {
         func(data);                             //回调逻辑层
     }
     //            facade.SendMessageCommand(data.evName, data.evParam); //通知MonoBehaviour层
 }
Example #17
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null)
     {
         func(data);                         //回调逻辑层
     }
     Debug.Log(data.evName + data.evParam);
     //facade.SendMessageCommand(data.evName, data.evParam); //通知View层
 }
Example #18
0
    void OnExtractUpdate(float progress)
    {
        NotiData data = new NotiData(NotiConst.EXTRACT_UPDATE, progress);

        if (m_SyncEvent != null)
        {
            m_SyncEvent(data);
        }
    }
        private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            //float pro = (float)e.ProgressPercentage / 100f;
            //Debug.LogWarning(pro);
            string   value = string.Format("{0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));
            NotiData data  = new NotiData(MessageTypes.UPDATE_PROGRESS, value);

            SyncEvent?.Invoke(data);
        }
Example #20
0
    /// <summary>
    /// 调用方法
    /// </summary>
    void OnExtractFile(List <object> evParams)
    {
        ///------------------通知更新面板解压完成--------------------
        NotiData data = new NotiData(NotiConst.UPDATE_DOWNLOAD, null);

        if (m_SyncEvent != null)
        {
            m_SyncEvent(data);
        }
    }
Example #21
0
        private void OnExtractFile(List <object> evParams)
        {
            Debuger.LogWarning("Thread evParams: >>" + evParams.Count, new object[0]);
            NotiData data = new NotiData("UpdateDownload", null);

            if (this.m_SyncEvent != null)
            {
                this.m_SyncEvent(data);
            }
        }
Example #22
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null)
     {
         func(data);                                 //回调逻辑层
     }
     Dispatcher.instance.ToMainThread(() => {
         Messenger.Broadcast(data.evName, data.evParam); //通知View层
     });
 }
Example #23
0
        private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            string   value = string.Format("{0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));
            NotiData data  = new NotiData(NotiData.UPDATE_PROGRESS, value);

            if (m_SyncEvent != null)
            {
                m_SyncEvent(data);
            }
        }
Example #24
0
        void ProgressFinish(object sender, AsyncCompletedEventArgs e)
        {
            UnityEngine.Debug.Log("ThreadManager ProgressFinish");
            sw.Reset();
            NotiData data = new NotiData(NotiData.UPDATE_DOWNLOAD, currDownFile);

            if (m_SyncEvent != null)
            {
                m_SyncEvent(data);
            }
        }
Example #25
0
    /// <summary>
    /// 调用方法
    /// </summary>
    void OnExtractFile(List <object> evParams)
    {
        Debugger.LogWarning("Thread evParams: >>" + evParams.Count);
        ///------------------通知更新面板解压完成--------------------
        NotiData data = new NotiData(NotiConst.UPDATE_DOWNLOAD, null);

        if (mSyncEvent != null)
        {
            mSyncEvent(data);
        }
    }
Example #26
0
    /// <summary>
    /// 线程完成
    /// </summary>
    /// <param name="data"></param>
    void OnThreadCompleted(NotiData data)
    {
//		switch (data.evName) {
//		case NotiConst.UPDATE_EXTRACT:  //解压一个完成
//                    //
//			break;
//		case NotiConst.UPDATE_DOWNLOAD: //下载一个完成
//			downloadFiles.Add (data.evParam.ToString ());
//			break;
//		}
    }
Example #27
0
        /// <summary>
        /// 调用方法
        /// </summary>
        void OnExtractFile(List <object> evParams)
        {
            UnityEngine.Debug.LogWarning("Thread evParams: >>" + evParams.Count);

            ///------------------通知更新面板解压完成--------------------
            NotiData data = new NotiData(QFrameworkMsg.UPDATE_DOWNLOAD, null);

            if (m_SyncEvent != null)
            {
                m_SyncEvent(data);
            }
        }
Example #28
0
    /// <summary>
    /// 解压完成通知
    /// </summary>
    /// <param name="evParams"></param>
    void OnExtractFile(List <object> evParams)
    {
        UnityEngine.Debug.Log("Thread evParams: >> " + evParams.Count);

        //通知更新面板解压完成
        NotiData data = new NotiData(NotiConst.UPDATE_DOWNLOAD, null);

        if (m_SyncEvent != null)
        {
            m_SyncEvent(data);
        }
    }
Example #29
0
    void OnFileDownloaded(byte[] fileBytes)
    {
        if (fileBytes == null || fileBytes.Length <= 0)
        {
            NotiData data = new NotiData(NotiConst.UPDATE_FAILED, this.FileName, LanguageTips.UPDATE_FAILED);
            if (OnComplete != null)
            {
                OnComplete(data);                      //回调逻辑层
            }
            //MessageBox.DisplayMessageBox(string.Format("{0}: {1}", UpdateTips.UPDATE_FAILED, FileName), 0, (go) =>
            //{
            //    AssetsCtrl.downloadFailed = true;
            //});

            if (OnWorkDone != null)
            {
                OnWorkDone(this);
            }
            download = null;
            return;
        }

        string path = Path.GetDirectoryName(LocalPath);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        if (LocalPath.CustomEndsWith(".ab"))
        {
            BeginDecompressExtract(LocalPath, fileBytes);
        }
        else
        {
            DownloadFileMD5 = MD5.ComputeHashString(fileBytes);
            if (DownloadFileMD5 != SrcMD5)
            {
                throw new Exception(LanguageTips.UPDATE_MD5_ERROR);
            }
            if (File.Exists(LocalPath))
            {
                File.Delete(LocalPath);
            }
            File.WriteAllBytes(LocalPath, fileBytes);
        }
        download = null;
        if (OnWorkDone != null)
        {
            OnWorkDone(this);
        }
    }
Example #30
0
    /// <summary>
    /// 线程完成
    /// </summary>
    /// <param name="data"></param>
    void OnThreadCompleted(NotiData data)
    {
        switch (data.evName)
        {
        case NotificationID.UPDATE_EXTRACT:      //解压一个完成

            break;

        case NotificationID.UPDATE_DOWNLOAD:     //下载一个完成
            downloadFiles.Add(data.evParam.ToString());
            break;
        }
    }
Example #31
0
        private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) {
            //UnityEngine.Debug.Log(e.ProgressPercentage);
            /*
            UnityEngine.Debug.Log(string.Format("{0} MB's / {1} MB's",
                (e.BytesReceived / 1024d / 1024d).ToString("0.00"),
                (e.TotalBytesToReceive / 1024d / 1024d).ToString("0.00")));
            */
            //float value = (float)e.ProgressPercentage / 100f;

            string value = string.Format("{0} kb/s", (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds).ToString("0.00"));
			NotiData data = new NotiData(QFrameworkMsg.UPDATE_PROGRESS, value);
            if (m_SyncEvent != null) m_SyncEvent(data);

            if (e.ProgressPercentage == 100 && e.BytesReceived == e.TotalBytesToReceive) {
                sw.Reset();

				data = new NotiData(QFrameworkMsg.UPDATE_DOWNLOAD, currDownFile);
                if (m_SyncEvent != null) m_SyncEvent(data);
            }
        }
Example #32
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data) {
     if (this.func != null) func(data);  //回调逻辑层
     facade.SendMessageCommand(data.evName, data.evParam); //通知View层
 }
Example #33
0
 private void OnSyncEvent(NotiData data)
 {
     if (mFunc != null) mFunc(data);  //回调逻辑层
     GameFacade.SendMessageCommand(data.mEvName, data.mEvParam); //通知View层
 }
        /// <summary>
        /// 调用方法
        /// </summary>
        void OnExtractFile(List<object> evParams)
        {
            Debuger.LogWarning("Thread evParams: >>" + evParams.Count);

            ///------------------通知更新面板解压完成--------------------
            NotiData data = new NotiData(NotiConst.UPDATE_DOWNLOAD, null);
            if (m_SyncEvent != null) m_SyncEvent(data);
        }
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data)
 {
     if (this.func != null) func(data);  //回调逻辑层
     facade.SendNotification(data.evName, data.evParam); //通知View层
 }
Example #36
0
 /// <summary>
 /// 通知事件
 /// </summary>
 /// <param name="state"></param>
 private void OnSyncEvent(NotiData data) {
     if (this.func != null) func(data); 
 }
 public void Call(NotiData param0)
 {
     func.BeginPCall();
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
 public void CallWithSelf(NotiData param0)
 {
     func.BeginPCall();
     func.Push(self);
     func.PushObject(param0);
     func.PCall();
     func.EndPCall();
 }
Example #39
0
 /// <summary>
 /// 线程完成
 /// </summary>
 /// <param name="data"></param>
 void OnThreadCompleted(NotiData data)
 {
     switch (data.evName) {
         case NotiConst.UPDATE_EXTRACT:  //解压一个完成
         //
         break;
         case NotiConst.UPDATE_DOWNLOAD: //下载一个完成
         downloadFiles.Add(data.evParam.ToString());
         break;
     }
 }
Example #40
0
        /// <summary>
        /// 调用方法
        /// </summary>
        void OnExtractFile(List<object> evParams) {
            UnityEngine.Debug.LogWarning("Thread evParams: >>" + evParams.Count);

            ///------------------通知更新面板解压完成--------------------
			NotiData data = new NotiData(QFrameworkMsg.UPDATE_DOWNLOAD, null);
            if (m_SyncEvent != null) m_SyncEvent(data);
        }