Hey ho,
i am working on a twitch chat statistics bot (in java), and got a small problem with the connection.
how should the response pong look like? and to which server should it send to?
atm i am opening a Socket connection to irc.twitch.tv.
socket = new Socket(irc.twitch.tv, 6667);
Joining the chat and everything works fine, i just get time out after i received the second PING.
atm my response pong looks like this:
sender.write("PONG tmi.twitch.tv");
sender is a BufferedWriter with a OutputstreamWriter bound to the socket:
sender = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
Also, this should only be in the event of a PING messages. You need to listen to the socket in a BufferedReader and respond with an appropriate pong message (the same trailing characters as you received). I believe you need to be sending “PONG :tmi.twitch.tv”, but this should be generated from the message received, as in the linked example.
Dynamically generating the response would also allow you to gather chat statistics from big events not hosted on tmi.twitch.tv. I suggest avoiding literals with something like: