public ChatApiClient(TwitchChatConfig config) { Logger = new LogManager(config.LogLevel); if (config.ChatProvider == null) { _client = new TcpSocketClient(Logger, config.ChatHost, config.ChatPort); } else { _client = config.ChatProvider; } _client.MessageReceived += OnMessageInternalAsync; }
public TwitchChatClient(TwitchChatConfig config) : base(config, CreateApiClient(config)) { _stateLock = new SemaphoreSlim(1, 1); _chatLogger = LogManager.CreateLogger("Chat"); ApiClient.SentChatMessage += async cmd => await _chatLogger.DebugAsync($"Sent {cmd}").ConfigureAwait(false); ApiClient.ReceivedChatEvent += ProcessMessageAsync; LeftChannel += async n => await _chatLogger.InfoAsync($"Left {n}").ConfigureAwait(false); JoinedChannel += async n => await _chatLogger.InfoAsync($"Joined {n}").ConfigureAwait(false); LatencyUpdated += async(old, val) => await _chatLogger.InfoAsync($"Latency = {val} ms").ConfigureAwait(false); }
public TwitchChatClient(TwitchChatConfig config) : base(config) { _config = config; _chat = new ChatApiClient(config); }
private static TwitchChatApiClient CreateApiClient(TwitchChatConfig config) => new TwitchChatApiClient(config.RestClientProvider, config.SocketClientProvider, config.CacheClientProvider, config.ClientId, TwitchConfig.UserAgent, config.SocketHost);