/// <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); }
/// <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; } }
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); } } }
// 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); } }
public void Call(NotiData param0) { func.BeginPCall(); func.PushObject(param0); func.PCall(); func.EndPCall(); }
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); } } }
/// <summary> /// 通知事件 /// </summary> /// <param name="data"></param> private void OnSyncEvent(NotiData data) { if (this.func != null) { func(data); } }
/// <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); //回调逻辑层 } } }
/// <summary> /// 通知事件 /// </summary> /// <param name="state"></param> private void OnSyncEvent(NotiData data) { if (null != this._callback) { _callback(data); } //通知View层 }
/// <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层 }
/// <summary> /// 添加到事件队列 /// </summary> public void AddEvent(NotiData ev, Action <NotiData> callback) { lock (m_lockObj) { _callback = callback; events.Enqueue(ev); } }
public void CallWithSelf(NotiData param0) { func.BeginPCall(); func.Push(self); func.PushObject(param0); func.PCall(); func.EndPCall(); }
private void OnSyncEvent(NotiData data) { if (mFunc != null) { mFunc(data); //回调逻辑层 } GameFacade.SendMessageCommand(data.mEvName, data.mEvParam); //通知View层 }
private void OnSyncEvent(NotiData data) { if (this.func != null) { this.func(data); } base.facade.SendMessageCommand(data.evName, data.evParam); }
/// <summary> /// 通知事件 /// </summary> /// <param name="state"></param> private void OnSyncEvent(NotiData data) { if (this.func != null) { func(data); //回调逻辑层 } // facade.SendMessageCommand(data.evName, data.evParam); //通知MonoBehaviour层 }
/// <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层 }
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); }
/// <summary> /// 调用方法 /// </summary> void OnExtractFile(List <object> evParams) { ///------------------通知更新面板解压完成-------------------- NotiData data = new NotiData(NotiConst.UPDATE_DOWNLOAD, null); if (m_SyncEvent != null) { m_SyncEvent(data); } }
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); } }
/// <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层 }); }
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); } }
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); } }
/// <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); } }
/// <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; // } }
/// <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); } }
/// <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); } }
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); } }
/// <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; } }
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); } }
/// <summary> /// 通知事件 /// </summary> /// <param name="state"></param> private void OnSyncEvent(NotiData data) { if (this.func != null) func(data); //回调逻辑层 facade.SendMessageCommand(data.evName, data.evParam); //通知View层 }
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层 }
/// <summary> /// 通知事件 /// </summary> /// <param name="state"></param> private void OnSyncEvent(NotiData data) { if (this.func != null) func(data); }
/// <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; } }
/// <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); }