public Task Disconnect() { if (TwitchClient.IsConnected) { TwitchClient.Disconnect(); } TwitchClientMessageQueue.Clear(); TwitchWhisperMessageQueue.Clear(); _connectedEvent.Reset(); _disconnectedEvent.Set(); return(_taskManager.Stop(true)); }
public async Task SendWhisper(string message, string target, string sender = Bot.BotNickname) { await Task.Run(() => { TwitchWhisperMessageQueue.QueueWhisper(message, target, sender); }); }
public async Task Connect() { try { using (await _connectionLock.LockAsync().ConfigureAwait(false)) { await Disconnect().ConfigureAwait(false); _taskManager.ClearException(); _disconnectedEvent.Reset(); var cancelSource = new CancellationTokenSource(); CancelToken = cancelSource.Token; var tasks = new Task[] { CancelToken.Wait(), TwitchClientMessageQueue.RunSendQueue(CancelToken), TwitchWhisperMessageQueue.RunSendQueue(CancelToken) }; await _taskManager.Start(tasks, cancelSource).ConfigureAwait(false); await ConnectClient().ConfigureAwait(false); } } catch (Exception ex) { await _taskManager.SignalError(ex).ConfigureAwait(false); throw; } }