New on the blog: Real-Time Without WebSockets — Se...
# wheels-dev
p
New on the blog: Real-Time Without WebSockets — Server-Sent Events in Wheels 4.0. <https://blog.wheels.dev/posts/server-sent-events-wheels-4> Most "real-time" features are one-directional — the server has news, the client wants to hear it. You don't need WebSockets for that. You need a pipe that pushes, and Wheels 4.0 ships SSE as first-class controller helpers. What it covers: •
renderSSE(data=..., event=..., retry=...)
— one event per request, browser auto-reconnects. Spec-covered, engine-safe, holds no thread. The one to reach for. • The streaming trio —
initSSEStream()
returns the raw writer, then
sendSSEEvent
/
sendSSEComment
(keep-alive heartbeat) /
closeSSEStream
for long-lived pushes. •
isSSERequest()
— serve SSE to EventSource clients and HTML to everyone else from one action. • The bounded streaming loop — timeout cap,
writer.checkError()
disconnect detection, heartbeats,
sleep
, try/finally close. CFML holds a worker thread for the whole connection, so this part is mandatory. • The one real sharp edge:
initSSEStream()
is engine-fragile on BoxLang and not spec-covered end-to-end. Hand-test streaming per engine;
renderSSE
has no such caveat. About 4 lines of controller code for server-to-client updates, no second protocol.