using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Threading; using LitJson; public class ServerListParser : SingletonMonobehaviour { bool hasCommonResult = false; ServerInfoCommon serverInfoCommon; bool hasPlayerResult = false; ServerInfoPlayer serverInfoPlayer; public void PushCommonServerListRawData(string content) { hasCommonResult = false; ThreadPool.QueueUserWorkItem((object aaa) => { serverInfoCommon = JsonMapper.ToObject(content); hasCommonResult = true; }); } public void PushPlayerServerListRawData(string content) { hasPlayerResult = false; Debug.Log("ServerListParser:" + content); if (content == "" || content == "{}") return; JsonData RankArr = JsonMapper.ToObject(content); if (RankArr["player"]["group_list"].Count == 0) return; ThreadPool.QueueUserWorkItem((object aaa) => { serverInfoPlayer = JsonMapper.ToObject(content); hasPlayerResult = true; SetIsInWhiteList(); }); } public void ReportCommonResult() { if (serverInfoCommon != null) { ServerListCenter.Instance.SetServerlistCommon(serverInfoCommon); } } public void ReportPlayerResult() { if (serverInfoPlayer != null) { ServerListCenter.Instance.SetServerListPlayer(serverInfoPlayer); } } public void SetIsInWhiteList() { DebugUtility.Instance.isWhiteListAccount = serverInfoPlayer.white == 1; } private void Update() { if (hasCommonResult) { ReportCommonResult(); hasCommonResult = false; } if (hasPlayerResult) { ReportPlayerResult(); hasPlayerResult = false; } } }