% Generated by roxygen2: do not edit by hand % Please edit documentation in R/server.R \name{format_sse} \alias{format_sse} \title{Format Server-Sent Event} \usage{ format_sse(data, event = NULL, id = NULL, retry = NULL) } \arguments{ \item{data}{The data payload. Will be prefixed with "data: " on each line.} \item{event}{[default NULL] Optional event type (e.g., "message", "error").} \item{id}{[default NULL] Optional event ID for client reconnection.} \item{retry}{[default NULL] Optional retry interval in milliseconds.} } \value{ A character string formatted as an SSE message, ready to pass to \code{conn$send()}. } \description{ Helper function to format messages according to the Server-Sent Events (SSE) specification. Use with \code{\link[=handler_stream]{handler_stream()}} to create SSE endpoints. } \details{ Server-Sent Events is a W3C standard for server-to-client streaming over HTTP, supported natively by browsers via the \code{EventSource} API. SSE is commonly used for real-time updates, notifications, and LLM token streaming. SSE messages have this format: \if{html}{\out{