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}"); } }
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}"); } }
public void RevokeToken() { Logger.Instance.LogMessage(TracingLevel.INFO, "TwitchTokenManager: RevokeToken Called"); this.token = null; SaveToken(); RaiseTokenChanged(); }
private TwitchChat() { ChatMessage = DEFAULT_CHAT_MESSAGE; PageCommand = DEFAULT_PAGE_COMMAND; ResetClient(); TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged; token = TwitchTokenManager.Instance.GetToken(); }
private TwitchChat() { ChatMessage = DEFAULT_CHAT_MESSAGE; ResetClient(); TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged; token = TwitchTokenManager.Instance.GetToken(); GlobalSettingsManager.Instance.OnReceivedGlobalSettings += Instance_OnReceivedGlobalSettings; GlobalSettingsManager.Instance.RequestGlobalSettings(); }
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(); }
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(); }
private void Instance_TokensChanged(object sender, TwitchTokenEventArgs e) { token = e.Token; Logger.Instance.LogMessage(TracingLevel.INFO, $"Tokens changed, reconnecting"); Connect(DateTime.Now); }
public TwitchComm() { TwitchTokenManager.Instance.TokensChanged += Instance_TokensChanged; token = TwitchTokenManager.Instance.GetToken(); }
private void Instance_TokensChanged(object sender, TwitchTokenEventArgs e) { token = e.Token; }
public TwitchTokenEventArgs(TwitchToken token) { Token = token; }