Let’s say I want to build dynamic chat app.
I want to update users activity status. I can do this with backend requests every x seconds.
But for example Discord can do this without any requests (nothing in network tab in Chrome).
How can I do this? Thanks!
>Solution :
For this type of requests it’s the server who sends the requests to the client
not the usual HTTP requests where the client request something and the server sends the response so it’s either you use SSE (server-sent-event) unidirectional tunnel or you use a socket which is bidirectional tunnel (socket.io for example) but for this need sse are better so you don’t need to check every x seconds the server notifies the clients subscribed to this tunnel it’s like a notification
check these links:
server-sent-event-1
server-sent-event-2