WebSocket connection handler.
WebSocket connection handler.
(handshake {:keys [on-connect on-message on-close on-error] :as callback})
(handshake {{:keys [on-connect on-message on-close on-error]} :callback})
(handshake callback)
(handshake next-handler callback)
Returns a new web socket session handler with optional next handler to invoke
if the web socket connection fails. A HttpHandler
which will process the
HttpServerExchange
and do the actual handshake/upgrade to WebSocket.
Function arguments:
next-handler
The handler that is invoked if there are no web socket
headers.
callback
The instance of the WebSocketConnectionCallback
or callback
configuration map.
Callback configuration options provided “as is” or as :callback
key:
:on-connect
The function (fn [{:keys [callback exchange channel]}])
.
:on-message
The function (fn [{:keys [callback channel text data]}])
.
:text
and binary message is
provided in :data
.:on-close
The function (fn [{:keys [callback channel code reason]}])
.
:code
is status code to close messages:
http://tools.ietf.org/html/rfc6455#section-7.4:on-error
The function (fn [{:keys [callback channel error]}])
.
Returns a new web socket session handler with optional next handler to invoke if the web socket connection fails. A `HttpHandler` which will process the `HttpServerExchange` and do the actual handshake/upgrade to WebSocket. Function arguments: - `next-handler` The handler that is invoked if there are no web socket headers. - `callback` The instance of the `WebSocketConnectionCallback` or callback configuration map. Callback configuration options provided “as is” or as `:callback` key: - `:on-connect` The function `(fn [{:keys [callback exchange channel]}])`. + Is called once the WebSocket connection is established, which means the handshake was successful. - `:on-message` The function `(fn [{:keys [callback channel text data]}])`. + Is called when listener receives a message. + The text message is provided in `:text` and binary message is provided in `:data`. - `:on-close` The function `(fn [{:keys [callback channel code reason]}])`. + Is called once the WebSocket connection is closed. + The `:code` is status code to close messages: http://tools.ietf.org/html/rfc6455#section-7.4 - `:on-error` The function `(fn [{:keys [callback channel error]}])`. + Is called on WebSocket connection error. + Default implementation just closes WebSocket connection.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close