コード例 #1
0
        private void LoadToken(TwitchToken globalToken)
        {
            try
            {
                if (globalToken == null)
                {
                    Logger.Instance.LogMessage(TracingLevel.ERROR, "TwitchTokenManager: Failed to load tokens, deserialized globalToken is null");
                    return;
                }

                if (token != null && token.Token == globalToken.Token && token.TokenLastRefresh == globalToken.TokenLastRefresh)
                {
                    return;
                }

                token = new TwitchToken()
                {
                    Token            = globalToken.Token,
                    TokenLastRefresh = globalToken.TokenLastRefresh
                };

                Logger.Instance.LogMessage(TracingLevel.INFO, $"TwitchTokenManager: Token initialized. Last refresh date was: {token.TokenLastRefresh}");
                RaiseTokenChanged();
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TwitchTokenManager: Exception loading tokens: {ex}");
            }
        }
コード例 #2
0
        private void LoadToken(TwitchToken globalToken)
        {
            try
            {
                if (globalToken == null)
                {
                    Logger.Instance.LogMessage(TracingLevel.ERROR, "TwitchTokenManager: Failed to load tokens, deserialized globalToken is null");
                    OAuthTokenListener.Instance.StartListener(Constants.OAUTH_PORT, Constants.OAUTH_REDIRECT_URL);
                    return;
                }

                if (token != null && token.Token == globalToken.Token && token.TokenLastRefresh == globalToken.TokenLastRefresh)
                {
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"TwitchTokenManager: LoadToken called for EXISTING token. Token Size: {token?.Token?.Length}");
                    return;
                }

                token = new TwitchToken()
                {
                    Token            = globalToken.Token,
                    TokenLastRefresh = globalToken.TokenLastRefresh
                };

                Logger.Instance.LogMessage(TracingLevel.INFO, $"TwitchTokenManager: Token initialized. Last refresh date was: {token.TokenLastRefresh} Token Size: {token?.Token?.Length}");
                if (String.IsNullOrWhiteSpace(token.Token))
                {
                    Logger.Instance.LogMessage(TracingLevel.WARN, "Existing token in Global Settings is empty!");
                }
                RaiseTokenChanged();
            }
            catch (Exception ex)
            {
                Logger.Instance.LogMessage(TracingLevel.ERROR, $"TwitchTokenManager: Exception loading tokens: {ex}");
            }
        }
コード例 #3
0
 public void RevokeToken()
 {
     Logger.Instance.LogMessage(TracingLevel.INFO, "TwitchTokenManager: RevokeToken Called");
     this.token = null;
     SaveToken();
     RaiseTokenChanged();
 }
コード例 #4
0
 private TwitchChat()
 {
     ChatMessage = DEFAULT_CHAT_MESSAGE;
     PageCommand = DEFAULT_PAGE_COMMAND;
     ResetClient();
     TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged;
     token = TwitchTokenManager.Instance.GetToken();
 }
コード例 #5
0
        private TwitchChat()
        {
            ChatMessage = DEFAULT_CHAT_MESSAGE;
            ResetClient();
            TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged;
            token = TwitchTokenManager.Instance.GetToken();

            GlobalSettingsManager.Instance.OnReceivedGlobalSettings += Instance_OnReceivedGlobalSettings;
            GlobalSettingsManager.Instance.RequestGlobalSettings();
        }
コード例 #6
0
 public void SetToken(TwitchToken token)
 {
     if (token != null && (this.token == null || token.TokenLastRefresh > this.token.TokenLastRefresh))
     {
         Logger.Instance.LogMessage(TracingLevel.INFO, "TwitchTokenManager: New token set");
         this.token = token;
         if (ValidateToken())
         {
             SaveToken();
         }
         else
         {
             Logger.Instance.LogMessage(TracingLevel.WARN, "TwitchTokenManager: Could not validate token with twitch");
             this.token = null;
         }
     }
     RaiseTokenChanged();
 }
コード例 #7
0
 public void SetToken(TwitchToken token)
 {
     if (token != null && (this.token == null || token.TokenLastRefresh > this.token.TokenLastRefresh))
     {
         Logger.Instance.LogMessage(TracingLevel.INFO, $"New token set Token Size: {token?.Token?.Length}");
         this.token = token;
         if (ValidateToken())
         {
             SaveToken();
         }
         else
         {
             Logger.Instance.LogMessage(TracingLevel.ERROR, "Could not validate token with twitch");
             this.token = null;
         }
     }
     RaiseTokenChanged();
 }
コード例 #8
0
 private void Instance_TokensChanged(object sender, TwitchTokenEventArgs e)
 {
     token = e.Token;
     Logger.Instance.LogMessage(TracingLevel.INFO, $"Tokens changed, reconnecting");
     Connect(DateTime.Now);
 }
コード例 #9
0
 public TwitchComm()
 {
     TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged;
     token = TwitchTokenManager.Instance.GetToken();
 }
コード例 #10
0
 private void Instance_TokensChanged(object sender, TwitchTokenEventArgs e)
 {
     token = e.Token;
 }
コード例 #11
0
 public TwitchTokenEventArgs(TwitchToken token)
 {
     Token = token;
 }