public void ClearData() { TLogger.Log("清空事件队列"); eventQueue.Clear(); }
private void OnComplete() { bool flag = this.callback != null; if (flag) { this.callback(this); } THttpDown.LoadingDown.Remove(this); TLogger.Log(this.url + ":下载完毕", null, null); }
public void TriggerEvent(IEvent evt) { //if (GameConfig.DebugModule) //{ // string msg = string.Format("TriggerEvent :{0}", evt.ToSring()); // Logger.DebugInfo(msg, "EventCenter", "TriggerEvent"); //} string msg = string.Format("TriggerEvent :{0}", evt.ToSring()); TLogger.Log(msg); this.eventQueue.Enqueue(evt); }
/// <summary> /// 初始化地图 /// </summary> /// <param name="xmlManager">新的地图信息</param> public void InitMap(MapXMLManager xmlManager) { _mapXmlManager = xmlManager; if (_mapXmlManager != null) { StartInitMap(); } else { Debug.LogError("MapInitControl.InitMap() _mapXmlManager内容是空的!"); TLogger.Log("_mapXmlManager内容是空的!", "MapInitControl", "InitMap"); } }
void Start() { TLogger.Log("测试输出一个Log~~~", "TestLoomAndTLogger", "Start"); Loom.StartSingleThread(() => { TLogger.Log("测试输出StartSingleThread线程~~~", "TestLoomAndTLogger", "Loom -- StartSingleThread"); }); Loom.QueueOnMainThread(() => { TLogger.Log("测试输出QueueOnMainThread线程~~~", "TestLoomAndTLogger", "Loom -- QueueOnMainThread"); }); }
//程序入口 protected virtual void Awake() { //核心不能销毁 DontDestroyOnLoad(this.gameObject); //线程模块 Loom.Init(); //日志模块 TLogger.Instance.ToString(); TLogger.Log("基础模块开始初始化.", "MainControl", "Awake - IniMainModules"); IniMainModules(); TLogger.Log("基础模块初始化完成.", "MainControl", "Awake - IniMainModules"); TLogger.Log("边缘模块开始初始化.", "MainControl", "Awake - IniMarginalModules"); IniMarginalModules(); TLogger.Log("边缘模块初始化完成.", "MainControl", "Awake - IniMarginalModules"); TLogger.Log("游戏初始化完成.", "MainControl", "Awake"); }
private void Run() { int num = 0; string content = string.Format("url:{0}, contentType:{1}", this.url, this.contentType); TLogger.Log(content, "HttpDwon", "Run"); bool flag = !this.isGet; if (flag) { content = string.Format("post参数:" + this.GetRequestString(), new object[0]); TLogger.Log(content, "HttpDwon", "Run"); } try { while (!this.DownComplete()) { int num2 = num; num = num2 + 1; bool flag2 = num >= 3; if (flag2) { break; } this.progress = 0f; this.HaveError = false; content = string.Format("第{0}次重新下载", num); TLogger.Log(content, "HttpDwon", "Run"); } this.OnComplete(); this.DestroySelf(); } catch (Exception ex) { TLogger.Log(ex.Message + "/n/n" + ex.StackTrace, null, null); } finally { GC.Collect(); } }
public void ParseXML(string xmlString) { if (xmlString == null || string.IsNullOrEmpty(xmlString)) { Debug.LogError("MapXMLManager.ParseXML() xml内容是空的!"); TLogger.Log("xml内容是空的!", "MapXMLManager", "ParseXML"); return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlString); XmlNode spaceConfine = doc.SelectSingleNode("/MapManager/SpaceConfine"); if (spaceConfine != null) { _spaceConfine = new SpaceConfine(); _spaceConfine.ParseXML(spaceConfine); } else { Debug.LogError("MapXMLManager.ParseXML() spaceConfine节点不存在!"); TLogger.Log("spaceConfine节点不存在!", "MapXMLManager", "ParseXML"); } XmlNode SpaceObjList = doc.SelectSingleNode("/MapManager/SpaceObjList"); if (SpaceObjList != null) { _spaceObjList = new List <SpaceObj>(); for (int i = 0; i < SpaceObjList.ChildNodes.Count; i++) { SpaceObj obj = new SpaceObj(); obj.ParseXML(SpaceObjList.ChildNodes[i]); _spaceObjList.Add(obj); } } }
private bool DownComplete() { Stream stream = null; HttpWebResponse httpWebResponse = null; HttpWebRequest httpWebRequest = null; TArrayBuffer <byte> tArrayBuffer = null; long num = 0L; bool result; try { httpWebRequest = (HttpWebRequest)WebRequest.Create(this.url); httpWebRequest.Timeout = this.requestTimeOut; httpWebRequest.ContentType = this.contentType; HttpRequestCachePolicy cachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); httpWebRequest.CachePolicy = cachePolicy; bool flag = this.isGet; if (flag) { httpWebRequest.Method = "GET"; } else { httpWebRequest.Method = "POST"; byte[] requestBytes = this.GetRequestBytes(); httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.ContentLength = (long)requestBytes.Length; using (Stream requestStream = httpWebRequest.GetRequestStream()) { requestStream.Write(requestBytes, 0, requestBytes.Length); requestStream.Close(); } } httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); stream = httpWebResponse.GetResponseStream(); stream.ReadTimeout = this.readTimeOut; tArrayBuffer = new TArrayBuffer <byte>(); byte[] array = new byte[1024]; int num2; while ((num2 = stream.Read(array, 0, array.Length)) > 0) { tArrayBuffer.Write(array, 0, num2); num += (long)num2; this.progress = (float)((double)num / (double)this.maxLength); } byte[] array2 = tArrayBuffer.Read(tArrayBuffer.Available); int num3 = array2.Length; this.data = new byte[num3]; Array.Copy(array2, this.data, num3); TLogger.Log("读取字节流长度:" + num3, "HttpDwon", "Run"); bool flag2 = this.progress < 1f; if (flag2) { this.HaveError = true; TLogger.ErrorInfo("下载错误:文件下载流已经读完数据,但是下载的文件长度小于服务器,这可能是由于本地网络突然中断导致!!", null, null); result = false; } else { this.HaveError = false; result = true; } } catch (WebException ex) { this.HaveError = true; TLogger.ErrorInfo(ex.ToString(), null, null); TLogger.ErrorInfo("webEx.Status = " + ex.Status, null, null); bool flag3 = ex.Status == WebExceptionStatus.ProtocolError; if (flag3) { TLogger.ErrorInfo("response.StatusCode = " + ((HttpWebResponse)ex.Response).StatusCode, null, null); TLogger.ErrorInfo("response.StatusDescription = " + ((HttpWebResponse)ex.Response).StatusDescription, null, null); } bool flag4 = ex.Status == WebExceptionStatus.Timeout; if (flag4) { result = false; } else { result = true; } } catch (IOException ex2) { this.HaveError = true; TLogger.ErrorInfo(ex2.ToString(), null, null); result = true; } catch (Exception ex3) { this.HaveError = true; TLogger.ErrorInfo(ex3.ToString(), null, null); result = true; } finally { bool flag5 = tArrayBuffer != null; if (flag5) { tArrayBuffer.DestroySelf(); tArrayBuffer = null; } bool flag6 = stream != null; if (flag6) { stream.Close(); stream = null; } bool flag7 = httpWebResponse != null; if (flag7) { httpWebResponse.Close(); httpWebResponse = null; } } return(result); }