/// <summary>
        /// Rechecks the status of the providers for changes
        /// </summary>
        public void RefreshAuthStatus()
        {
            lock (_tokenCacheLock)
            {
                foreach (var kvp in _providers)
                {
                    string key = kvp.Key;

                    if (!_tokenCache.ContainsKey(key))
                    {
                        _tokenCache[key] = false;
                    }

                    bool wasValid = _tokenCache[key];
                    bool isValid  = _providers[key].IsTokenValid();

                    if (isValid != wasValid)
                    {
                        _tokenCache[key] = isValid;
                        TokenStatusChanged?.Invoke(this, new TokenStatusEventArgs()
                        {
                            ProviderKey = key,
                            OldValue    = wasValid,
                            NewValue    = isValid
                        });
                    }
                }
            }
        }
 private void RaiseTokenChanged()
 {
     TokenStatusChanged?.Invoke(this, EventArgs.Empty);
     if (token != null)
     {
         TokensChanged?.Invoke(this, new TwitchTokenEventArgs(new TwitchToken()
         {
             Token = token.Token, TokenLastRefresh = token.TokenLastRefresh
         }));
     }
     else
     {
         TokensChanged?.Invoke(this, new TwitchTokenEventArgs(null));
     }
 }
 private void RaiseTokenChanged()
 {
     TokenStatusChanged?.Invoke(this, EventArgs.Empty);
     if (token != null)
     {
         TokensChanged?.Invoke(this, new TwitchTokenEventArgs(new TwitchToken()
         {
             Token = token.Token, TokenLastRefresh = token.TokenLastRefresh
         }));
     }
     else
     {
         TokensChanged?.Invoke(this, new TwitchTokenEventArgs(null));
         OAuthTokenListener.Instance.StartListener(Constants.OAUTH_PORT, Constants.OAUTH_REDIRECT_URL);
     }
 }
예제 #4
0
 private void RaiseTokenChanged()
 {
     TokenStatusChanged?.Invoke(this, EventArgs.Empty);
     if (token != null)
     {
         Logger.Instance.LogMessage(TracingLevel.INFO, $"TwitchTokenManager raising new token change. Token Size: {token?.Token?.Length}");
         TokensChanged?.Invoke(this, new TwitchTokenEventArgs(new TwitchToken()
         {
             Token = token.Token, TokenLastRefresh = token.TokenLastRefresh
         }));
     }
     else
     {
         Logger.Instance.LogMessage(TracingLevel.WARN, "TwitchTokenManager raising EMPTY token change");
         TokensChanged?.Invoke(this, new TwitchTokenEventArgs(null));
     }
 }