Commucation with external server

Hi everyone!
I’m making a little game where viewers can interact with the game the streamer is playing. To do this, I need an overlay with some controls that notify the server hosted by the streamer that a button has been pushed.

What would be the best, most secure, and lag-free way of organising this? Should inputs from the viewer be transmitted to the EBS, which would communicate with the external server via websocket? Or would I need the use of PubSub?

I’m very new to the Twitch API so all of this is still a little confusing, even after reading the doc.
Thank you!
Kromah

Twitch PubSub in extensions is for sending to the Twitch Extension from your EBS

To send from your extension to your EBS, it would be best to test what works best for you, whether that is via WebSocket or HTTP Post, it’s up to you to decide what works best for you and your Game.

Time to start testing!

Thank you for your answer!

but the EBS is a back end running on Twitch, right? What I need is a way to communicate with an external server that would take the viewers’ input and apply them in game.
So say the viewer presses a button, the input is sent to the EBS, but how would the EBS send this input to the game server (being hosted on the streamer’s computer)?

No

You host the EBS.

A twitch extension is like a website,
Where the front end is static HTML/JS/CSS and hosted on a different server to your backend.

Your host and fully control the backend, Twitch hosts the static CDN

Viewer button press sends to the server/EBS.
The game also connects to the server/EBS
The EBS gets the button press and sends it to the right game.

I do this with an extension I run, there is software on the streamers computer that makes a websocket connection to my server, with a unique key to ID the streamer. And I can send data from the Twitch Extension to/from that software via my EBS

1 Like

Oh. That absolutely solves my problem then :astonished:
Thanks a lot @BarryCarlyon, I’m going to try this right away then

1 Like

Just to come back to the solution you use: if I understand correctly, you own a server that acts as a middleman between the viewers’ extensions and the streamers’ EBS?
Wouldn’t there be a solution where the viewers extensions could directly be talking to the streamer’s EBS via websocket (in a secure way, obviously)?

You shouldn’t have users communicating directly with anything running on the Streamers machine because then you would need for the streamer to open ports to the internet to let those connections come in, and you would also be exposing the streamers IP to users which could be a privacy violation and a security issue.

You also shouldn’t be exposing your extensions secret to anything running on the Streamers side either, which means that even if you did have users sending data to the streamer, they would have no way to verify the JWT.

Using a server to proxy data between streamer and viewers protects the streamers privacy and allows you to verify the JWT to ensure it’s legitimate traffic before sending it on to the streamer (who can connect as a client to your server, meaning they wont have to open any ports).

2 Likes

That makes a lot of sense then. Thank you!