public IEnumerator Download() { // 请求游戏版本 string webURL = _patcher.GetWebServerURL(); string postContent = _patcher.GetWebPostContent(); MotionLog.Log($"Beginning to request from web : {webURL}"); MotionLog.Log($"Web post content : {postContent}"); WebPostRequest download = new WebPostRequest(webURL); download.SendRequest(postContent); yield return(download); // Check fatal if (download.HasError()) { download.ReportError(); download.Dispose(); PatchEventDispatcher.SendGameVersionRequestFailedMsg(); yield break; } string responseContent = download.GetResponse(); MotionLog.Log($"Succeed get response from web : {responseContent}"); download.Dispose(); _patcher.ParseResponseContent(responseContent); _patcher.SwitchNext(); }
public IEnumerator Download() { // 请求游戏版本 string webURL = GameLauncher.GetWebServerURL(); string postContent = GetWebPostContent(); GameLog.Log($"Beginning to request from web : {webURL}"); GameLog.Log($"Post content : {postContent}"); WebPostRequest download = new WebPostRequest(webURL); download.SendRequest(postContent, 30); yield return(download); // Check fatal if (download.HasError()) { download.ReportError(); download.Dispose(); PatchEventDispatcher.SendGameVersionRequestFailedMsg(); yield break; } string responseContent = download.GetResponse(); download.Dispose(); // 解析游戏版本信息 try { GameLog.Log($"Response content : {responseContent}"); WebResponse response = JsonUtility.FromJson <WebResponse>(responseContent); Version gameVersion = new Version(response.GameVersion); int resourceVersion = response.ResourceVersion; bool foundNewApp = response.FoundNewApp; bool forceInstall = response.ForceInstall; string appURL = response.AppURL; PatchUpdater.Instance.GameVersion = gameVersion; PatchUpdater.Instance.ResourceVersion = resourceVersion; if (foundNewApp) { PatchEventDispatcher.SendFoundNewAppMsg(forceInstall, appURL, gameVersion.ToString()); } else { PatchUpdater.Instance.SwitchNext(); } } catch (Exception) { Debug.LogError($"Parse web response failed : {responseContent}"); PatchEventDispatcher.SendGameVersionParseFailedMsg(); } }