SSE
encodes the Server-Sent Events wire format (WHATWG HTML ยง9.2.6).
Every function here returns one complete block, terminated by the blank line
that dispatches it. Carriage returns and newlines are stripped from field
values, and a data value spanning several lines becomes one data: line per
line.
comment-line
(Fn [(Ref String a)] String)
(comment-line text)
encodes a comment line. Clients ignore it; it keeps the stream and any proxy in front of it from timing out.
encode
(Fn [(Maybe String), (Ref String a), (Maybe String), (Maybe Int)] String)
(encode name payload id retry)
encodes one event with an optional name, id and retry.
retry is the reconnection time in milliseconds a client should wait before
reopening the stream. An empty payload still emits an empty data: line, so
the event is dispatched with an empty payload rather than dropped.
event
(Fn [(Ref String a), (Ref String b)] String)
(event name value)
encodes an event with a name, which the client listens for by
that name instead of message.