Unity/Game Communication

Hi There,

I am currently looking at making an extension for one of our games, the idea would be for the game to trigger a vote every so often on the extension so the viewers could choose an action to trigger within the game.

I have the front end for the extension currently designed and a simple backend triggering the votes to users and collecting the votes, but I’m a little stuck on how to trigger the initial vote from within the game to the ebs.

Looking into TwitchLib it has the option for OnChannelExtensionBroadcast which would handle the return back to the game, but I don’t seem to be able to find a way to correctly communicate with the extension/ebs from within the game itself.

I feel like I’m missing something simple haha, or I’m totally thinking of the puzzle in the wrong way.

Any help would be appreciated.

I can’t clearly find what this does in this library.

If you refer to https://swiftyspiffy.com/TwitchLib/PubSub/class_twitch_lib_1_1_pub_sub_1_1_twitch_pub_sub.html#a591a97841b79eeb6b4f145d3b0fca3e0

That is not directly supported by Twitch and can break/change at any time and it’s not advised to be used. It is not a “supported topic” - PubSub | Twitch Developers I also don’t think it works given the authentication requirements for that undocument/unsupported (for third parties) topic.

Twitch provides “extension pubsub”

Send from EBS: Extensions Reference | Twitch Developers
Send from Extension HTML/JS: Extensions Reference | Twitch Developers
Recieve in Extension HTML/JS: Extensions Reference | Twitch Developers

Extension PubSub is “designed” as a “Fan Out” solution to Extension Clients not a “Fan In” solution to your EBS (or game as in this example). Additionally “Extension Viewers” generally won’t be able to broadcast a message via PubSub since viewers lack the authorisation to do so.

This function can be called by the front end to send directly to PubSub. It uses the Twitch-provided JWT for broadcasters, to allow broadcasters to send a broadcast (channel) or whisper message. Broadcasters cannot send to global.

So likely can’t be used for the game to recieve results of a vote. Since you can’t get the votes as they are cast, as the instance of the extension for a plain user doesn’t have the authority to broadcast.

Thats up to you to determine, design and create, Tiwtch doesn’t provide anything in this regard.

Which is used by your EBS (or other extension frontends) to send a messages to instance of the extension running on Twitch.


Game → any medium → EBS → via Extension PubSub → HTML
Game → any medium → EBS → any medium → HTML

HTML → any medium → EBS → any medium → Game

“Any Medium” is repaced with something you design and create

Generally for between Game ↔ EBS and I’m rolling a Socket
And for HTML → EBS I’m using plain JS Fetch making HTTP POST requests.
And Extension PubSub for EBS to HTML

1 Like

Thanks for the quick and epic reply, that has cleared quite a few bits up for me. I’ll start looking into some socket goodness :smiley: