private async void ReconnectButtonOnClickHandler() { try { ConnectionPopup connectionPopup = _uiManager.GetPopup <ConnectionPopup>(); Func <Task> connectFunc = async() => { bool success = true; try { await _backendDataControlMediator.LoginAndLoadData(); } catch (Exception) { // HACK: ignore to allow offline mode } if (!_backendFacade.IsConnected) { success = false; } if (success) { connectionPopup.Hide(); } else { connectionPopup.ShowFailedOnMenu(); } }; _uiManager.DrawPopup <ConnectionPopup>(); connectionPopup.ConnectFunc = connectFunc; await connectionPopup.ExecuteConnection(); } catch (Exception e) { Debug.LogException(e); OpenAlertDialog( $"Reconnect failed. Please check your Internet connection.\n\nAdditional info: {e.GetType().Name} [{e.Message}]"); } }
public async void Update() { if (_selfPage == null) { return; } if (!_selfPage.activeInHierarchy || GameClient.Get <IAppStateManager>().AppState != Enumerators.AppState.APP_INIT) { return; } if (!_isLoaded) { _percentage += 1f; _loaderBar.fillAmount = Mathf.Clamp(_percentage / 100f, 0.03f, 1f); if (_percentage >= 100) { _isLoaded = true; _progressBar.gameObject.SetActive(false); _pressAnyText.gameObject.SetActive(true); } } else { if (!Input.anyKey) { return; } if (!_pressAnyText.gameObject.activeSelf) { return; } _pressAnyText.gameObject.SetActive(false); if (_backendDataControlMediator.LoadUserDataModel() && _backendDataControlMediator.UserDataModel.IsValid) { ConnectionPopup connectionPopup = _uiManager.GetPopup <ConnectionPopup>(); Func <Task> connectFunc = async() => { bool success = true; try { await _backendDataControlMediator.LoginAndLoadData(); } catch (GameVersionMismatchException e) { success = false; _uiManager.DrawPopup <LoginPopup>(); _uiManager.GetPopup <LoginPopup>().Show(e); } catch (Exception e) { // HACK: ignore to allow offline mode Debug.LogWarning(e); } connectionPopup.Hide(); if (success) { GameClient.Get <IAppStateManager>().ChangeAppState(Enumerators.AppState.MAIN_MENU); } }; _uiManager.DrawPopup <ConnectionPopup>(); connectionPopup.ConnectFunc = connectFunc; await connectionPopup.ExecuteConnection(); } else { _uiManager.DrawPopup <LoginPopup>(); } } }
private async void PressedBetaHandler() { GameClient.Get <ISoundManager>() .PlaySound(Enumerators.SoundType.CLICK, Constants.SfxSoundVolume, false, false, true); string betaKey = _betaKeyInputField.text.Trim(); bool isBetaKeyValid = betaKey.Length == 12; try { isBetaKeyValid &= CryptoUtils.HexStringToBytes(betaKey).Length == 6; } catch (Exception) { isBetaKeyValid = false; } if (isBetaKeyValid) { // check if field is empty. Can replace with exact value once we know if there's a set length for beta keys SetUIState(LoginState.BetaKeyValidateAndLogin); GenerateKeysAndUserFromBetaKey(betaKey, out byte[] privateKey, out byte[] _, out string userId); try { isBetaKeyValid = await _backendFacade.CheckIfBetaKeyValid(betaKey); if (!isBetaKeyValid) { throw new Exception("Tester key not registered"); } UserDataModel userDataModel = new UserDataModel(userId, betaKey, privateKey) { // HACK IsValid = true // IsValid = false }; _backendDataControlMediator.SetUserDataModel(userDataModel); await _backendDataControlMediator.LoginAndLoadData(); // HACK // userDataModel.IsValid = true; _backendDataControlMediator.SetUserDataModel(userDataModel); SuccessfulLogin(); } catch (GameVersionMismatchException e) { SetUIState(LoginState.RemoteVersionMismatch); UpdateVersionMismatchText(e); } catch (Exception e) { Debug.LogWarning(e); SetUIState(LoginState.BetaKeyValidationFailed); } } else { _uiManager.DrawPopup <WarningPopup>("Input a valid Tester Key"); } }