Exemple #1
0
        public async Task SendRawMessage(string message)
        {
            if (await _WaitForConnection())
            {
                await _outputStream.WriteLineAsync(message);

                await _outputStream.FlushAsync();
            }
            else
            {
                TimeoutException ex = new TimeoutException("Could not send message because the operation timed out before a valid connection was found.");
                ex.Data.Add("message", message);
                await OnConnectionException.InvokeAsync(this, new ConnectionExceptionEventArgs(ex));
            }
        }
Exemple #2
0
        public async Task <ITwitchIRCChannel> JoinChannel(string name)
        {
            if (await _WaitForConnection())
            {
                await _outputStream.WriteLineAsync(String.Format("JOIN #{0}", name));

                await _outputStream.FlushAsync();

                return(_channels.GetOrAdd(name, new TwitchIRCChannel(name, this)));
            }
            else
            {
                TimeoutException ex = new TimeoutException("Could not join channel because the operation timed out before a valid connection was found.");
                ex.Data.Add("channel", name);
                await OnConnectionException.InvokeAsync(this, new ConnectionExceptionEventArgs(ex));
            }
            return(null);
        }
Exemple #3
0
        public async Task LeaveChannel(ITwitchIRCChannel channel)
        {
            if (await _WaitForConnection())
            {
                ITwitchIRCChannel removed;
                if (_channels.TryRemove(channel.Name, out removed))
                {
                    await _outputStream.WriteLineAsync(String.Format("PART #{0}", channel.Name));

                    await _outputStream.FlushAsync();
                }
            }
            else
            {
                TimeoutException ex = new TimeoutException("Could not leave channel because the operation timed out before a valid connection was found.");
                ex.Data.Add("channel", channel);
                await OnConnectionException.InvokeAsync(this, new ConnectionExceptionEventArgs(ex));
            }
        }
Exemple #4
0
 private async Task _InvokeConnectionException(ConnectionExceptionEventArgs e)
 {
     await OnConnectionException.InvokeAsync(this, e);
 }