Beispiel #1
0
        /// <summary>
        /// Login to the server, and register the integration if applicable
        /// </summary>
        public LoginInfo Login(Guid integrationId, string version, string integrationName)
        {
            string currentToken = "";


            if (_loginInfo != null)
            {
                currentToken = _loginInfo.Token;
            }
            // Now call the login method on the server, and get the loginInfo class (provide old token for next re-login)
            _loginInfo = Server.Login(_thisInstance, currentToken);

            try
            {
                Server.RegisterIntegration(_loginInfo.Token, Constants.InstanceId, integrationId, version, integrationName, Constants.ManufacturerName);
            }
            catch
            {
                // on older systems this method does not exist so we will just silently ignore any exceptions - and with no retry. Consequences of failing are ignorable anyways
            }

            // React 30 seconds before token expires. (Never faster than 30 seconds after last renewal, but that ought not occur).
            // Default timeout 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);
        }
Beispiel #2
0
        /// <summary>
        /// Login to the server
        /// </summary>
        private LoginInfo Login()
        {
            string currentToken = "";


            if (_loginInfo != null)
            {
                currentToken = _loginInfo.Token;
            }
            // Now call the login method on the server, and get the loginInfo class (provide old token for next re-login)
            _loginInfo = Server.Login(_thisInstance, currentToken);

            // React 30 seconds before token expires. (Never faster than 30 seconds after last renewal, but that ought not occur).
            // Default timeout 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);
        }
Beispiel #3
0
 /// <summary>
 /// Logout from the server
 /// </summary>
 public void Logout()
 {
     Server.Logout(_thisInstance, _loginInfo.Token);
     _loginInfo = null;
     CancelCallbackTimer();
 }