(build-request-map request)
Create the request map from the HttpServletRequest object.
Create the request map from the HttpServletRequest object.
(configurator handshake-handler)
(configurator handshake-handler options)
Takes a handshake handler function and returns a server configurator that will add ring-like WebSocket handling to a jetty server. The handshake-handler is much like a ring HTTP request handler, and all upgrade requests will be directed to it. In order to establish a WebSocket connection, the handler should return a map with a status of 101. In addition a map of websocket event handler functions can be provided in the :ws-handlers key, as in the example below.
{:status 101
:ws-handlers {:on-connect (fn [ws]
(log/debug "WebSocket connected" ws))
:on-close (fn [ws code reason]
(log/debug "Websocket closed" ws code reason))
:on-error (fn [ws err]
(log/error err "Websocket connection error!" ws))
:on-text (fn [ws text]
(log/debug "Websocket text recieved" ws text))
:on-binary (fn [ws bytes offset len]
(log/debug "Websocket binary data recived" len)}}
The first argument to each handler will be an object fulfilling the WebSocket protocol.
An options object can be provided as a second argument which supports the key :ws-factory-configurator, a function that will be passed a WebSocketServletFactory for configuration
Takes a handshake handler function and returns a server configurator that will add ring-like WebSocket handling to a jetty server. The handshake-handler is much like a ring HTTP request handler, and all upgrade requests will be directed to it. In order to establish a WebSocket connection, the handler should return a map with a status of 101. In addition a map of websocket event handler functions can be provided in the :ws-handlers key, as in the example below. {:status 101 :ws-handlers {:on-connect (fn [ws] (log/debug "WebSocket connected" ws)) :on-close (fn [ws code reason] (log/debug "Websocket closed" ws code reason)) :on-error (fn [ws err] (log/error err "Websocket connection error!" ws)) :on-text (fn [ws text] (log/debug "Websocket text recieved" ws text)) :on-binary (fn [ws bytes offset len] (log/debug "Websocket binary data recived" len)}} The first argument to each handler will be an object fulfilling the WebSocket protocol. An options object can be provided as a second argument which supports the key :ws-factory-configurator, a function that will be passed a WebSocketServletFactory for configuration
(update-servlet-response res {:keys [status headers]})
Copy fields from a response map to the ServletUpgradeResponse object
Copy fields from a response map to the ServletUpgradeResponse object
A websocket connection protocol
A websocket connection protocol
(close! this)
(close! this status reason)
Closes the websocket connection.
Closes the websocket connection.
(connected? this)
Returns true if the websocket is still connected.
Returns true if the websocket is still connected.
(send! this msg)
Sends a string message to the client.
Sends a string message to the client.
(send-bin! this data)
Sends binary data to the client.
Sends binary data to the client.
(unwrap this)
Ideally you won't need this, but the current API is pretty basic, so in case you need to do something more complicated, this returns the underlying org.eclipse.jetty.websocket.api.Session
Ideally you won't need this, but the current API is pretty basic, so in case you need to do something more complicated, this returns the underlying org.eclipse.jetty.websocket.api.Session
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close