/// <summary> /// Terminates the user's session and releases their data. /// </summary> /// <param name="cb">The result of the web request.</param> public void LogOut(LogoutCallback cb) { if (string.IsNullOrEmpty(sessionToken)) { Debug.LogWarning("Cannot log out on users that aren't logged in."); return; } if (m_WebCoroutine != null) { Debug.LogError("A request is already in progress. Please wait for the operation to complete."); return; } // Terminate session CustomAuthenticator authenticator = new CustomAuthenticator(m_AppService); authenticator.LogOut(cb, userID, sessionToken); userID = 0; sessionToken = ""; displayName = null; //banType = BanType.None; lastLoginTime = DateTime.UtcNow.AddDays(-1); }
public void Logout(LogoutCallback callback = null, ExceptionCallback ExCal = null) { DSRESTCommand cmd = getConnection().CreateCommand(); cmd.setRequestType(DSHTTPRequestType.GET); cmd.setText("TCompanyTweet.Logout"); cmd.prepare(get_TCompanyTweet_Logout_Metadata()); InternalConnectionDelegate LogoutDel = () => { if (callback != null) { try { callback.DynamicInvoke(); } catch (Exception ex) { if (ExCal != null) { getConnection().syncContext.Send(new SendOrPostCallback(x => ExCal.DynamicInvoke(ex.InnerException)), null); } else { getConnection().syncContext.Send(new SendOrPostCallback(x => BaseExCal.DynamicInvoke(ex.InnerException)), null); } } } }; getConnection().execute(cmd, this, LogoutDel, ExCal); }
/// <summary> /// Terminates a user's session. /// </summary> /// <param name="cb">The result of the web request.</param> /// <param name="userID">The ID of the user to log out.</param> /// <param name="sessionToken">The session token of the user to log out.</param> public void LogOut(LogoutCallback cb, uint userID, string sessionToken) { if (m_WebCoroutine != null) { Debug.LogError("A request is already in progress. Please wait for the operation to complete."); return; } Dictionary <string, string> formData = new Dictionary <string, string>(); formData.Add("UserID", userID.ToString(CultureInfo.InvariantCulture)); formData.Add("SessionToken", sessionToken); m_WebCoroutine = m_CoroutineOwner.StartCoroutine(OnLogOutResponse(m_AppService.apiUrl + "authentication/logout.php", formData, cb)); }
/// <summary> /// Initiate a blocking logout request. This will return when the logout /// handshake has completed or when <code>Settings.LOGOUT_TIMEOUT</code> /// has expired and the network layer is manually shut down /// </summary> public void Logout() { AutoResetEvent logoutEvent = new AutoResetEvent(false); LogoutCallback callback = delegate(List <LLUUID> inventoryItems) { logoutEvent.Set(); }; OnLogoutReply += callback; // Send the packet requesting a clean logout RequestLogout(); // Wait for a logout response. If the response is received, shutdown // will be fired in the callback. Otherwise we fire it manually with // a NetworkTimeout type if (!logoutEvent.WaitOne(Client.Settings.LOGOUT_TIMEOUT, false)) { Shutdown(DisconnectType.NetworkTimeout); } OnLogoutReply -= callback; }
private IEnumerator OnLogOutResponse(string url, Dictionary <string, string> formData, LogoutCallback cb) { using (UnityWebRequest request = WebConfig.Post(url, formData)) { yield return(request.SendWebRequest()); m_WebCoroutine = null; ErrorResponse error = WebConfig.ProcessGenericErrors(request); if (error != null) { cb?.Invoke(error); yield break; } JsonResponse response = JsonResponse.FromJson(request.downloadHandler.text); switch (response.code) { case 1: cb?.Invoke(null); break; default: cb?.Invoke(WebConfig.GetUnknownError(request)); break; } } }