Home > Back-end >  How does Twitch's chat fetch messages? [closed]
How does Twitch's chat fetch messages? [closed]

Time:10-02

Example: https://www.twitch.tv/popout/amouranth/chat?darkpopout

I've looked at the network tab and it doesn't seem to transfer any Ajax data from Twitch to the browser. Yet the messages appear.

I'm trying to make my own chat thing for myself which blocks all kinds of messages I don't want to see. But I can't even figure out how they transfer them over the network. Apparently by magic?

CodePudding user response:

It uses a websocket, refresh the page and filter by WS in the networking tab. It will be one of the first connections established when the chat loads.

CodePudding user response:

I've no idea why you're getting downvoted, you asked a good question.

To answer the question, Twitch uses websockets to communicate. Thats why you don't see any AJAX call on your console.

Clients establish a WebSocket connection to our server, listen on topics they care about, and get messages on those topics in real time. Each command or message sent between the client and server is a JSON string encapsulated in one WebSocket frame.

Source: https://dev.twitch.tv/docs/pubsub#:~:text=Clients establish a WebSocket connection,encapsulated in one WebSocket frame.

  • Related