Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server Sent Events - Targeting response to specific clients

Tags:

People also ask

What are server sent events used for?

SSE is commonly used to send message updates or continuous data streams to a browser client. In a nutshell, a server-sent event is when updates are pushed (rather than pulled, or requested) from a server to a browser.

What are the differences between long polling Websockets and server sent events?

Long-polling opens an HTTP request and remains open until an update is received. Upon receiving an update, a new request is immediately opened awaiting the next update. Server-sent events(SSE) rely on a long-lived HTTP connection, where updates are continuously sent to the client.

What is server sent events in Java?

What are Server-Sent Events? SSE definition states that it is an http standard that allows a web application to handle a unidirectional event stream and receive updates whenever the server emits data. In simple terms, it is a mechanism for unidirectional event streaming.

Which element is required in a web application to operate the server sent events?

To use Server-Sent Events in a web application, you would need to add an <eventsource> element to the document. The src attribute of <eventsource> element should point to an URL which should provide a persistent HTTP connection that sends a data stream containing the events.


Using server sent events is fairly straight forward when all clients have to receive updates with the same data. For example updating the HTML clients on stock prices.

How can I target the response to different clients.

For example:

Client A needs to be notified on events that only interest client A (i.e. a new email has arrived for client A).

Client B doesn't need to be updated when client A receives an email.