fix(sse): send plain string body for subsequent SSE events
http-kit's send! after the initial response expects a plain string, not a full response map with status/headers. Sending a response map was silently dropped, so SSE clients never received change notifications after the initial "connected" message. Verified working: toggling a todo in one tab updates the other tab within ~30ms via SSE.
This commit is contained in:
@@ -66,15 +66,12 @@
|
||||
(swap! sse-clients update group disj ch))))
|
||||
|
||||
(defn- sse-notify!
|
||||
"Send an SSE event to all listeners of the given groups."
|
||||
"Send an SSE event to all listeners of the given groups.
|
||||
After the initial response, http-kit send! takes a plain string body."
|
||||
[groups]
|
||||
(doseq [group groups
|
||||
ch (get @sse-clients group)]
|
||||
(http/send! ch {:status 200
|
||||
:headers {"Content-Type" "text/event-stream"
|
||||
"Cache-Control" "no-cache"}
|
||||
:body (str "data: " group "\n\n")}
|
||||
false))) ;; false = don't close, keep streaming
|
||||
(http/send! ch (str "data: " group "\n\n") false)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Handlers
|
||||
|
||||
Reference in New Issue
Block a user