Please can somebody explain the listener on the react extensions-boilerplate example

Hi, I would like to understand this line. Excuse my ignorance

First of all, it is not firing. Is this normal that it does not fire since I have no EBS? (I am just using the example as is) Wouldn’t it fire and just return nothing?

And how is there is no websocket connection made.

Thank you

That function will listen to messages broadcast to the TwitchPubsub.

You can use

To broadcast such a message.

Their is one made to the Twitch PubSub system. It’s not made to your EBS but the main Twitch PubSub

Hi, thank you.

IF there are no message, shouldn’t the function’s log still show, as to know if it is working? Or will it only do the this.twitch.rig if there is a message?

Edit: and another thing, If someone is sending me messages to the pubsub, then i don’t need an EBS, right? How would I listen to an EBS? I am sorry, it is very confusing and I’m going crazy. Is there a case when I would need to create the sockets myself.

I can’t quite grasp the concepts

there is a pubsub where anyone can send messages and if they are for me or public I can listen to them, right?

And then on the other hand, what does an EBS do? is it in charge of sending those messages? Can the EBS and the front end communicate in other ways that is not the pubsub, or is it mandatory to go through the pubsub?

Any help with making this clear for me is highly appreciated

The callback function only fires when a message is recieved.

You would be sending messages to Twitch PubSub, not “someone”

EBS is just a fancy name for a “backend server”

if you are “creating sockets” yourself, then you’ll be connectiong to your Backend Server AKA EBS.

No. using the PubSub makes it easier for your to scale. You send one message to Twitch, Twitch copies it to all connected users. So you don’t need to worry about scaling your socket yourself.

But if I use pubsub the application cannot talk back right?

I read that in another thread but it was from 2017, so I just want to make sure

Your application can talk back. Depends what you are trying to talk back too.

You can use PubSub to talk to other PubSub connected users.

Provides a send function.

Or you can send from application/client/user to EBS via any javascript ajax function, such as fetch, jQuery.ajax or whatever.

Thank you.

Thank you very much for your help. I appreciate it