Exemple #1
0
 private void LoadedUserFromServer(WebRequestResponse response)
 {
     if (response.Succeeded)
     {
         dataManager.SetUser(response.Response <UserData>());
     }
 }
Exemple #2
0
 private void ResetTemporalUser(WebRequestResponse response)
 {
     if (response.Succeeded)
     {
         dataManager.ResetTemporalUser();
     }
 }
Exemple #3
0
 private void EmailUpdated(WebRequestResponse response)
 {
     if (response.Succeeded)
     {
         dataManager.LinkEmail(response.Response <UserData>().Email);
     }
 }
Exemple #4
0
        private void SaveAuthentication(WebRequestResponse webRequestResponse)
        {
            if (webRequestResponse.Succeeded)
            {
                requester.SaveAuthentication(webRequestResponse.Response <Authentication>());
                SaveAuthenticationLocally();
                onAuthTokenUpdate?.Invoke(requester.Authentication);
            }

            StartSynchronization();
        }
Exemple #5
0
        private IEnumerator Request(RequestContent requestContent, UnityAction <WebRequestResponse> response)
        {
            string parametres = requestContent.Parameters.ToQueryString();
            string url        = string.IsNullOrEmpty(parametres) ? GetURL(requestContent) : GetURL(requestContent) + InitParameters + parametres;

            if (secretToken != null)
            {
                requestContent.Headers.Add(SecretTokenHeader, secretToken);
            }

            if (Authentication != null)
            {
                requestContent.Headers.Add(TokenHeader, Authentication.Token);
                requestContent.Headers.Add(UsernameLogin, Authentication.Email != null ? Authentication.Email : Authentication.Username);
            }

            IWebRequest webRequest = requestContent.WebRequest;

            webRequest.SetUnityWebRequest(new UnityWebRequest(url, requestContent.RequestType));
            webRequest.SetDownloadHandler(new DownloadHandlerBuffer());
            if (!string.IsNullOrEmpty(requestContent.Content))
            {
                IWebUploadHandler webUploadHandler = requestContent.WebUploadHandler;
                webUploadHandler.AddContent(requestContent.Content);
                webRequest.SetUploadHandler(webUploadHandler.UploadHandler);
            }

            foreach (KeyValuePair <string, string> header in requestContent.Headers)
            {
                if (!string.IsNullOrEmpty(header.Key) && !string.IsNullOrEmpty(header.Value))
                {
                    webRequest.SetRequestHeader(header.Key, header.Value);
                }
            }

            yield return(webRequest.SendWebRequest());

            var webRequestResponse = new WebRequestResponse(webRequest);

            if (webRequestResponse.StatusCode == HttpStatusCode.Unauthorized)
            {
                unauthorizedResponse?.Invoke(webRequestResponse);
            }
            else
            {
                response?.Invoke(webRequestResponse);
            }
        }
Exemple #6
0
 internal void UnauthorizedConnectionDetected(WebRequestResponse response)
 {
     onUnauthorizedConnectionDetected?.Invoke(response);
 }
Exemple #7
0
 private void SynchronizationAttempt(WebRequestResponse response)
 {
     synching = false;
     onSynchronizationAttempt?.Invoke(response);
 }