Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public TwitchChatClient(TwitchChatConfig config) : base(config)
 {
     _config = config;
     _chat   = new ChatApiClient(config);
 }
Esempio n. 4
0
 private static TwitchChatApiClient CreateApiClient(TwitchChatConfig config)
 => new TwitchChatApiClient(config.RestClientProvider, config.SocketClientProvider, config.CacheClientProvider, config.ClientId, TwitchConfig.UserAgent, config.SocketHost);