Server-Sent Events need no websocket library, custom protocol or handshake. An
EventSource in a
browser, a for await loop on a server, or curl -N on the command line is a complete client.
Rebuild from the snapshot
Both streams send a full snapshot every time you connect or reconnect, then send changes as they happen. That one rule keeps your client simple:- When you connect, replace your local state with the snapshot.
- After that, apply each event as it arrives.
- If the connection drops, reconnect and replace your state again.