Liking cljdoc? Tell your friends :D

io.pedestal.http.sse

Support for Server Sent Events.

Support for Server Sent Events.
raw docstring

extract-stringclj

(extract-string map-or-str k)
source

sse-setupcljdeprecated

(sse-setup & args)

See start-event-stream. This function is for backward compatibility.

See start-event-stream. This function is for backward compatibility.
sourceraw docstring

start-event-streamcljdeprecated

(start-event-stream stream-ready-fn)
(start-event-stream stream-ready-fn heartbeat-delay)
(start-event-stream stream-ready-fn heartbeat-delay bufferfn-or-n)
(start-event-stream stream-ready-fn heartbeat-delay bufferfn-or-n opts)

Returns an interceptor which will start a Server Sent Event stream with the requesting client, and set the ServletResponse to go async. After the request handling context has been paused in the Servlet thread, stream-ready-fn will be called in a future, with the resulting context from setting up the SSE event stream.

opts is a map with optional keys:

:on-client-disconnect - A function of one argument which will be called when the client permanently disconnects.

DEPRECATED: Invoke start-stream from your own interceptor.

Returns an interceptor which will start a Server Sent Event stream
with the requesting client, and set the ServletResponse to go
async. After the request handling context has been paused in the
Servlet thread, `stream-ready-fn` will be called in a future, with
the resulting context from setting up the SSE event stream.

opts is a map with optional keys:

:on-client-disconnect - A function of one argument which will be
  called when the client permanently disconnects.

DEPRECATED: Invoke start-stream from your own interceptor.
sourceraw docstring

start-streamclj

(start-stream stream-ready-fn context)
(start-stream stream-ready-fn context heartbeat-delay)
(start-stream stream-ready-fn context heartbeat-delay bufferfn-or-n)
(start-stream stream-ready-fn context heartbeat-delay bufferfn-or-n opts)

Starts an SSE event stream and initiates a heartbeat to keep the connection alive. stream-ready-fn will be called with a core.async channel. The application can then put values on that channel to cause SSE events to be sent to the client.

Values are either maps or simple values; maps will contain keys :name, :data, and :id. These are converted to UTF-8 strings and sent to the client.

Non-map values are treated as if a map with just a :data key; the value is converted to a string and sent to the client.

If the data value spans multiple lines, then the event will repeat the data field once for each line.

Either the client or the application may close the channel to terminate and clean up the event stream; the client closes it by closing the connection.

The SSE's core.async buffer can either be a fixed buffer (n) or a 0-arity function that returns a buffer.

Arguments:

  • stream-ready-fn: passed the channel on which events may be conveyed, and the context
  • context - interceptor context
  • heartbeat-delay: time, in seconds, between heartbeats (defaults to 1)
  • bufferfn-or-n: a channel buffer size, or a no-args function that returns a buffer or buffer size

Options: :on-client-disconnect - callback passed the context when the client disconnects.

Returns the context with a :response key, and a :response-channel key (the channel to which events may be written).

Starts an SSE event stream and initiates a heartbeat to keep the
connection alive. `stream-ready-fn` will be called with a core.async
channel. The application can then put values on that channel to cause SSE events to be sent to the client.

Values are either maps or simple values; maps will contain keys :name, :data, and :id.
These are converted to UTF-8 strings and sent to the client.

Non-map values are treated as if a map with just a :data key; the value is converted to a string
and sent to the client.

If the data value spans multiple lines, then the event will repeat the data field once for
each line.

Either the client or the application may close the channel to terminate and
clean up the event stream; the client closes it by closing the
connection.

The SSE's core.async buffer can either be a fixed buffer (n) or a 0-arity
function that returns a buffer.

Arguments:
- stream-ready-fn: passed the channel on which events may be conveyed, and the context
- context - interceptor context
- heartbeat-delay: time, in seconds, between heartbeats (defaults to 1)
- bufferfn-or-n: a channel buffer size, or a no-args function that returns a buffer or buffer size

Options:
:on-client-disconnect - callback passed the context when the client disconnects.

Returns the context with a :response key, and a :response-channel key (the channel to which events
may be written).
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close