/// <summary> /// Login to the server /// </summary> /// <returns>Info of valid log in</returns> public LoginInfo Login() { string currentToken = ""; if (LoginInfo != null) { currentToken = LoginInfo.Token; } if (IsCServer) { // Now call the login method on the server, and get the loginInfo class (provide old token for next re-login) _loginInfo_CServer = CServer.Login(_thisInstance, currentToken); } else { // Now call the login method on the server, and get the loginInfo class (provide old token for next re-login) _loginInfo_EServer = _eServer.Login(_thisInstance, currentToken); } // React 30 seconds before token expires. (Never faster than 30 seconds after last renewal, but that ought not occur). // E-code's default timeout is 4 minutes, C-code's is 1 hour. double ms = LoginInfo.TimeToLive.TotalMilliseconds; ms = ms > 60000 ? ms - 30000 : ms; _tokenExpireTimer = new Timer(TokenExpireTimer_Callback, null, (int)ms, Timeout.Infinite); return(LoginInfo); }
/// <summary> /// Logout from the server /// </summary> public void Logout() { if (IsCServer) { CServer.Logout(_thisInstance, LoginInfo.Token); } else { _eServer.Logout(_thisInstance, LoginInfo.Token); } _loginInfo_CServer = null; _loginInfo_EServer = null; CancelCallbackTimer(); }