I have read the online documantation multiple times and find it a little unclear about a few things, but I’m sure there are simple answers and solutions to be found here.
So I have created a chat interaction mod for a Unity game in C# and have everything on that end working smoothly. For ease of implementation, I am using an HTTP listener (and hence HTTP communication protocol) for external communication, which by necessity needs to be 2-way because certain features of the extension need to enable/disable in real time. The data I wish to send is simple requests, returning only a JSON packet with a bit of data relating to the current game state. My question here is thus: everything in the documentation suggests that only secure connections are allowed. Am I misinterpreting this?
I am also unclear about whether Twitch can do fanout of the actual data across multiple viewers’ extension panels, or if the communication is per viewer (which could potentially affect performance if viewership is high.)
I know I could address both of these questions by using an EBS, but that is something I can’t afford at this stage. I do have a secure web server, but they throttle scripting access and halt all script requests if too many requests come through in a short time.
No, that is correct. HTTP and WebSocket requests need to be over HTTP and WSS.
Extension PubSub can send a whisper (message to 1 specific user), Broadcaster (message to all users on one channel), or Global (message to all users of your Extension on all channels). An EBS can send to all 3, but a broadcaster’s JWT wont be able to do a Global.
For interaction with a game, you would usually have the game communicate with an EBS and then that EBS can either send out PubSub broadcasts for updates about the state of the game for that channel, or allow users to send requests to the EBS to interact with the game in some way without disclosing the IP of the broadcaster.
Thanks. I’ll have to look into how to do the PubSub stuff then. Normally I would have the front end poll the back-end server, but it sounds like PubSub has the back end updating the front end instead, which is better for me, though it means a bit more code.
Yeah you’d go
For Game to Viewer
Game → Your Backend → Push over Extension PubSub to frontends
You might have the frontend call your backend for initial state. (or have your backend continutally sending/pushing to front end on a timer to achieve the same)
For Viewer to game
Extension FrontEnd → HTTPS (or socket or whatever) to your backend → Whatever down to the Game
I think I’ve got most of the concept down now. I guess what confused me the most is that the while a Twitch extension is tecnically just a web page, the communication that needs to occur in this case is all in the reverse direction “Game → Your Backend → Push over Extension PubSub to frontends” as you stated. It’s not a proplem, just a bit of extra code.
So I guess the last real question I have is relating to the push to PubSub. Does it do a single push to the front end (ie, update a main “page”) and the rest is handled internally (pushing it out to the viewers)? Or does the backend need to send multiple push events out to update the viewers? I would think from a normal web design that the panels would do some sort of internal polling to detect when they need to update, but again. the documentaion is unclear.
If you call “send extension pubsub” Twitch will send that message to all “subscribers to the stated topic”
There are three topics
- global - ALL users on ALL channels
- broadcast - ALL users on a single channel
- whisper - a single user on a single channel
You send one HTTP request from EBS to Twitch API and Twitch does the rest
You could build an extension that way it’s up to you.
one of my extensions will poll on load and poll once per hour, but it also listens to pubsub for real time updates.
it’s not documented as this is a “basic website thing” as apposed to a “twitch specific thing”
Thanks for the help. I’m sure I can make it work now.