public static bool IsNewApiVersion(JsonData jsonData) { try { VersionNumber versionNumber = VersionNumber.Parse(jsonData["APIVer"].ToString()); VersionNumber currentApiVersionOnDevice = GetCurrentApiVersionOnDevice(); CompareVersionNumber compareResult = (CompareVersionNumber)currentApiVersionOnDevice.CompareTo(versionNumber); switch (compareResult) { case CompareVersionNumber.MajorGreater: case CompareVersionNumber.MinorGreater: case CompareVersionNumber.PacthGreater: case CompareVersionNumber.Error: return(true); case CompareVersionNumber.MajorLess: case CompareVersionNumber.MinorLess: case CompareVersionNumber.PatchLess: case CompareVersionNumber.Equal: return(false); default: return(true); } } catch (Exception e) { Debug.LogError(e); return(false); } }
private void OnCheckVersionMessageResponse(string response) { #if UNITY_EDITOR if (Tracking) { PrintTrack(MethodBase.GetCurrentMethod().Name); PrintTrack("response: " + response); } #endif _checkVersionMessageRef = null; if (string.IsNullOrEmpty(response)) { Initialize(); return; } CheckVersionResponseMessage responseMessage = CheckVersionResponseMessage.FromJson(response); if (responseMessage == null) { Initialize(); return; } if (responseMessage.Status != BaseOnline.Success) { Initialize(); return; } VersionNumber currentApiVersionOnDevice = GetCurrentApiVersionOnDevice(); CompareVersionNumber compareResult = (CompareVersionNumber)currentApiVersionOnDevice.CompareTo(responseMessage.ApiVersion); switch (compareResult) { case CompareVersionNumber.MajorGreater: case CompareVersionNumber.MinorGreater: case CompareVersionNumber.PacthGreater: case CompareVersionNumber.Error: Initialize(); break; case CompareVersionNumber.MajorLess: case CompareVersionNumber.MinorLess: case CompareVersionNumber.PatchLess: _updating = false; if (_onNewApiVersion != null) { _onNewApiVersion(currentApiVersionOnDevice, responseMessage.ApiVersion); } break; case CompareVersionNumber.Equal: FinishInit(_currentApiClientId, _currentToken); break; } }
private void OnInitMessageResponse(string response) { #if UNITY_EDITOR if (Tracking) { PrintTrack(MethodBase.GetCurrentMethod().Name); PrintTrack("response: " + response); } #endif _initializeAppMessageRef = null; if (string.IsNullOrEmpty(response)) { FinishInit(); return; } InitializeAppResponseMessage responseMessage = InitializeAppResponseMessage.FromJson(response); if (responseMessage == null) { FinishInit(); return; } VersionNumber currentApiVersionOnDevice = GetCurrentApiVersionOnDevice(); CompareVersionNumber compareResult = (CompareVersionNumber)currentApiVersionOnDevice.CompareTo(responseMessage.ApiVersion); if (compareResult == CompareVersionNumber.Equal) { _currentApiClientId = responseMessage.ApiclientId; _currentToken = responseMessage.Token; FinishInit(responseMessage.ApiclientId, responseMessage.Token); } else { _updating = false; if (_onNewApiVersion != null) { _onNewApiVersion(currentApiVersionOnDevice, responseMessage.ApiVersion); } } }
private void OnCheckVersionMessageResponse(string response) { #if UNITY_EDITOR if (Tracking) { PrintTrack(MethodBase.GetCurrentMethod().Name); PrintTrack("response: " + response); } #endif _checkVersionMessageRef = null; if (string.IsNullOrEmpty(response)) { FinishUpdate(false); return; } CheckVersionResponseMessage responseMessage = CheckVersionResponseMessage.FromJson(response); if (responseMessage == null) { FinishUpdate(false); return; } if (!Directory.Exists(_dlcPath)) { UpdateFull(responseMessage.UrlDlcFull); return; } VersionNumber currentDLCVersionOnDevice = GetCurrentDLCVersionOnDevice(); CompareVersionNumber compareResult = (CompareVersionNumber)currentDLCVersionOnDevice.CompareTo(responseMessage.DlcVersion); // If dlc version on client greater than dlc version on server, // it's fatal error, must update full // If major version change, update full // else update version by version switch (compareResult) { case CompareVersionNumber.MajorGreater: case CompareVersionNumber.MinorGreater: case CompareVersionNumber.PacthGreater: case CompareVersionNumber.MajorLess: UpdateFull(responseMessage.UrlDlcFull); break; case CompareVersionNumber.MinorLess: case CompareVersionNumber.PatchLess: UpdateVersionByVersion(); break; case CompareVersionNumber.Error: FinishUpdate(false); break; case CompareVersionNumber.Equal: FinishUpdate(true); break; } }