Hey everyone,
I have been trying to get the chat messages back from a stream with not a lot of succes.
I kinda want an event that happens whenever someone enters a new message in the chat so I can use that. This is what I have right now:
class TwitchConnection
{
private TcpClient _tcpClient;
private StreamReader _inputStream;
private StreamWriter _outputStream;
public TwitchConnection(string userName, string password)
{
_tcpClient = new TcpClient("irc.chat.twitch.tv", 6667);
_inputStream = new StreamReader(_tcpClient.GetStream());
_outputStream = new StreamWriter(_tcpClient.GetStream());
_outputStream.WriteLine("PASS " + password);
_outputStream.WriteLine("NICK " + userName);
_outputStream.Flush();
}
public string ReadLine()
{
return _inputStream.ReadLine();
}
}
I tried creating my own “update loop” like this but it seems like it gets into an infinite loop somewhere.
public MainForm()
{
InitializeComponent();
_reading = false;
LblQuestion.Text = "";
Application.Idle += delegate { Invalidate(); UpdateLoop(); };
}
private void UpdateLoop()
{
if (_connection != null && _reading)
{
Console.WriteLine(_connection.ReadLine());
}
}
I am not experienced at all with the twitch api and that’s why I came here (Not a lot of youtube vids about this subject)\
Thanks in advance,
Patrick