private void LoadedUserFromServer(WebRequestResponse response) { if (response.Succeeded) { dataManager.SetUser(response.Response <UserData>()); } }
private void ResetTemporalUser(WebRequestResponse response) { if (response.Succeeded) { dataManager.ResetTemporalUser(); } }
private void EmailUpdated(WebRequestResponse response) { if (response.Succeeded) { dataManager.LinkEmail(response.Response <UserData>().Email); } }
private void SaveAuthentication(WebRequestResponse webRequestResponse) { if (webRequestResponse.Succeeded) { requester.SaveAuthentication(webRequestResponse.Response <Authentication>()); SaveAuthenticationLocally(); onAuthTokenUpdate?.Invoke(requester.Authentication); } StartSynchronization(); }
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); } }
internal void UnauthorizedConnectionDetected(WebRequestResponse response) { onUnauthorizedConnectionDetected?.Invoke(response); }
private void SynchronizationAttempt(WebRequestResponse response) { synching = false; onSynchronizationAttempt?.Invoke(response); }