Beispiel #1
0
        private async void RegisterAsync(string username, bool newUser)
        {
            var baseEvent = new BaseEventDataViewModel {
                UserName = username, NewUser = newUser
            };

            if (Application.internetReachability == NetworkReachability.NotReachable || _sending)
            {
                SaveRegisterInDB(baseEvent);
                return;
            }
            try
            {
                var(success, statusCode, registerResponse) = await _probaHttpClient.RegisterAsync(baseEvent);

                if (!success)
                {
                    SaveRegisterInDB(baseEvent);
                    return;
                }

                _basicData.UserId                = registerResponse.UserId;
                _basicData.ABTest                = registerResponse.AbTest;
                _basicData.CurrentUserName       = username;
                _basicData.SessionCount          = 0;
                _basicData.PurchesesCount        = 0;
                _basicData.VirtualPurchesesCount = 0;
                _basicData.CreationTime          = DateTime.UtcNow;
                _basicData.OverallPlayTime       = 0;

                PlayerPrefs.SetString("ProbaUserID", _basicData.UserId);
                PlayerPrefs.SetString("ProbaUserName", _basicData.CurrentUserName);
                PlayerPrefs.SetString("ProbaABTest", _basicData.ABTest);

                PROBA.ABTestReceive(_basicData.ABTest);

                new StartSessionViewModel(true);
            }
            catch (Exception e)
            {
                _probaLogger.LogError(e.Message, e.StackTrace);
                SaveRegisterInDB(baseEvent);
            }
        }
Beispiel #2
0
        private async void ExistingRegister(BaseEventDataViewModel baseEvent)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                OldRecordCouldNotSent();
                return;
            }
            try
            {
                var(success, statusCode, registerResponse) = await _probaHttpClient.RegisterAsync(baseEvent);

                if (!success)
                {
                    OldRecordCouldNotSent();
                    return;
                }

                _basicData.UserId                = registerResponse.UserId;
                _basicData.ABTest                = registerResponse.AbTest;
                _basicData.CurrentUserName       = baseEvent.UserName;
                _basicData.SessionCount          = 0;
                _basicData.PurchesesCount        = 0;
                _basicData.VirtualPurchesesCount = 0;
                _basicData.CreationTime          = DateTime.UtcNow;
                _basicData.OverallPlayTime       = 0;

                PlayerPrefs.SetString("ProbaUserID", _basicData.UserId);
                PlayerPrefs.SetString("ProbaUserName", _basicData.CurrentUserName);
                PlayerPrefs.SetString("ProbaABTest", _basicData.ABTest);

                PROBA.ABTestReceive(_basicData.ABTest);

                OldRecordSent();
            }
            catch (Exception e)
            {
                _probaLogger.LogError(e.Message, e.StackTrace);
                OldRecordCouldNotSent();
            }
        }