So, I have code that connects to tmi.twitch.tv successfully (ie. It connects, receives connection confirmation), then sends authentication data (sends “USER…”, “PASS…”, “NICK”… and receives the “maze” message), then joins channel (and receives user list). It even receives “PING” messages.
However, for life of me, I cannot get it to read messages typed in via the chat (at the twitch.tv website).
Here is the code that I’m using:
TcpClient clientSocket = new TcpClient();
.... Connection code -- all good
var stream = clientSocket.GetStream();
.... Authentication code -- all good
.... Join channel code -- all good
bool done = false;
while(!done)
{
string str = "";
byte[] buffer = new byte[1024];
int bytesRead = 0;
int readingPosition = 0;
while(stream.DataAvailable)
{
bytesRead = stream.Read(buffer, readingPosition , buffer.Length);
readingPosition += bytesRead;
str += Encoding.UTF8.GetString(buffer, 0, bytesRead);
}
Console.WriteLine(str);
..... other code, including stream and connection closing omitted for brevity.
}
The stream reading code, does not return anything when text is being typed in the “Joined” to channel. The only strings that ever get returned are the "PING"s from the sever.
Any suggestions?