Skip to content

Broadcast changes to fragments (SSE)

Alf Eaton requested to merge sse into master

Using Server-Sent Events, this allows a client to subscribe to a feed of updates and the server to broadcast a message to all subscribers when a resource is updated.

The SSE class that handles connections and broadcasts messages is an EventEmitter which clients connect to via a listener, which sends a message to the client whenever an update is emitted.

Each message has a unique identifier, which means that clients who have temporarily disconnected can send a "Last-Event-ID" header when they reconnect to request all the messages sent since then. Implementing this requires that the message history is stored somewhere (e.g. Redis), so this isn't done yet.

The updates are broadcast by the API route handlers rather than a generic response listener - this makes it easier to be more explicit about about the message type and contents.

Currently only changes to fragments and collections are broadcast.

Merge request reports