Server-Sent Events (SSE) is a unidirectional communication between the client and server. The client initiates the connection with the server using EventSource API.
The previously mentioned API can also listen to the events from the server, listen for errors, and close the connection.
consteventSource=newEventSource(url);eventSource.onmessage=({data})=>{consteventData=JSON.parse(data);// handling the data from the servereventSource.onerror=()=>{// error handlingeventSource.close();
A server can send the events in text/event-stream format to the client once the client establishes the client-server connection. A server can filter clients by query parameter and send them only the appropriate events.
In the following example, the NestJS server sends the events only to a specific client distinguished by its e-mail address.
what is the structure of you MessageData?
import { MessageEvent, MessageEventData } from './message-event.interface';
pdta: pass code pls
Once unpublished, all posts by zsevic will become hidden and only accessible to themselves.
If zsevic is not suspended, they can still re-publish their posts from their dashboard.