Hello! I am working on an Arduino based LED display that connects to Twitch chat using Websockets. My software skills are very poor, but based off some example code I am at the point where I can read messages or commands from chat and create effects on my LED array.
I would like to be able to either get notification on a new subscriber (or multiple), or I can just continuously check the total subscriber count and monitor if the number changes.
The Twitch Developer documentation was a bit hard to decipher for me. Can somebody please show me how to pull subscriber count or new subscriber notification using Websockets?
I have included the code that connects me to the channel for reference:
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
switch(type) {
// If the websocket connection is succesful, try to join the IRC server
case WStype_CONNECTED:
digitalWrite(onbLED,HIGH);
Serial.printf("[WSc] Connected to: %s\n", payload);
webSocket.sendTXT("PASS " + String(twitch_oauth_token) + "\r\n");
webSocket.sendTXT("NICK " + String(twitch_nick) + "\r\n");
webSocket.sendTXT("JOIN " + String(twitch_channel) + "\r\n");
webSocket.sendTXT("CAP REQ " + String(twitch_cap) + "\r\n"); //Tag request
break;