Liking cljdoc? Tell your friends :D

babashka.http-client.websocket

Code is very much based on hato's websocket code. Credits to @gnarroway!

Code is very much based on hato's websocket code. Credits to @gnarroway!
raw docstring

abort!clj

(abort! ws)

Closes this WebSocket's input and output abruptly.

Closes this WebSocket's input and output abruptly.
sourceraw docstring

close!clj

(close! ws)
(close! ws status-code reason)

Initiates an orderly closure of this WebSocket's output by sending a Close message with the given status code and the reason.

Initiates an orderly closure of this WebSocket's output by sending a
Close message with the given status code and the reason.
sourceraw docstring

ping!clj

(ping! ws data)

Sends a Ping message with bytes from the given buffer.

Sends a Ping message with bytes from the given buffer.
sourceraw docstring

pong!clj

(pong! ws data)

Sends a Pong message with bytes from the given buffer.

Sends a Pong message with bytes from the given buffer.
sourceraw docstring

send!clj

(send! ws data)
(send! ws data opts)

Sends a message to the WebSocket. data can be a CharSequence (e.g. string), byte array or ByteBuffer

Options:

  • :last: this is the last message, defaults to true
Sends a message to the WebSocket.
`data` can be a CharSequence (e.g. string), byte array or ByteBuffer

Options:
* `:last`: this is the last message, defaults to `true`
sourceraw docstring

websocketclj

(websocket {:keys [client] :as opts})

Builds java.net.http.Websocket client.

  • :uri - the uri to request (required). May be a string or map of :scheme (required), :host (required), :port, :path and :query
  • :headers - a map of headers for the initial handshake`
  • :client - a client as produced by client. If not provided a default client will be used.
  • :connect-timeout Sets a timeout for establishing a WebSocket connection (in millis).
  • :subprotocols - sets a request for the given subprotocols.
  • :async - return CompleteableFuture of websocket

Callbacks options:

  • :on-open - [ws], called when a WebSocket has been connected.
  • :on-message - [ws data last] A textual/binary data has been received.
  • :on-ping - [ws data] A Ping message has been received.
  • :on-pong - [ws data] A Pong message has been received.
  • :on-close - [ws status reason] Receives a Close message indicating the WebSocket's input has been closed.
  • :on-error - [ws err] An error has occurred.
Builds `java.net.http.Websocket` client.
* `:uri` - the uri to request (required).
   May be a string or map of `:scheme` (required), `:host` (required), `:port`, `:path` and `:query`
* `:headers` - a map of headers for the initial handshake`
* `:client` - a client as produced by `client`. If not provided a default client will be used.
* `:connect-timeout` Sets a timeout for establishing a WebSocket connection (in millis).
* `:subprotocols` - sets a request for the given subprotocols.
* `:async` - return `CompleteableFuture` of websocket

Callbacks options:
* `:on-open` - `[ws]`, called when a `WebSocket` has been connected.
* `:on-message` - `[ws data last]` A textual/binary data has been received.
* `:on-ping` - `[ws data]` A Ping message has been received.
* `:on-pong` - `[ws data]` A Pong message has been received.
* `:on-close` - `[ws status reason]` Receives a Close message indicating the WebSocket's input has been closed.
* `:on-error` - `[ws err]` An error has occurred.
sourceraw docstring

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

× close