Liking cljdoc? Tell your friends :D

hato.websocket


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

request->WebSocketListenerclj

(request->WebSocketListener {:keys [on-open on-message on-ping on-pong on-close
                                    on-error]})

Constructs a new WebSocket listener to receive events for a given WebSocket connection.

Takes a map of:

  • :on-open Called when a WebSocket has been connected. Called with the WebSocket instance.
  • :on-message A textual/binary data has been received. Called with the WebSocket instance, the data, and whether this invocation completes the message.
  • :on-ping A Ping message has been received. Called with the WebSocket instance and the ping message.
  • :on-pong A Pong message has been received. Called with the WebSocket instance and the pong message.
  • :on-close Receives a Close message indicating the WebSocket's input has been closed. Called with the WebSocket instance, the status code, and the reason.
  • :on-error An error has occurred. Called with the WebSocket instance and the error.
Constructs a new WebSocket listener to receive events for a given WebSocket connection.

Takes a map of:

- `:on-open`    Called when a `WebSocket` has been connected. Called with the WebSocket instance.
- `:on-message` A textual/binary data has been received. Called with the WebSocket instance, the data, and whether this invocation completes the message.
- `:on-ping`    A Ping message has been received. Called with the WebSocket instance and the ping message.
- `:on-pong`    A Pong message has been received. Called with the WebSocket instance and the pong message.
- `:on-close`   Receives a Close message indicating the WebSocket's input has been closed. Called with the WebSocket instance, the status code, and the reason.
- `:on-error`   An error has occurred. Called with the WebSocket instance and the error.
sourceraw docstring

send!clj

(send! ws data)
(send! ws data {:keys [last?] :or {last? true}})

Sends a message to the WebSocket.

data can be a CharSequence (e.g. string) or ByteBuffer

Sends a message to the WebSocket.

`data` can be a CharSequence (e.g. string) or ByteBuffer
sourceraw docstring

Sendablecljprotocol

Protocol to represent sendable message types for a WebSocket. Useful for custom extensions.

Protocol to represent sendable message types for a WebSocket. Useful for custom extensions.

-send!clj

(-send! data last? ws)
sourceraw docstring

websocketclj

(websocket uri opts)

Builds a new WebSocket connection from a request object and returns a future connection.

Arguments:

  • uri a websocket uri
  • opts (optional), a map of:
    • :http-client An HttpClient - will use a default HttpClient if not provided
    • :listener A WebSocket$Listener - alternatively will be created from the handlers passed into opts: :on-open, :on-message, :on-ping, :on-pong, :on-close, :on-error
    • :headers Adds the given name-value pair to the list of additional HTTP headers sent during the opening handshake.
    • :connect-timeout Sets a timeout for establishing a WebSocket connection (in millis).
    • :subprotocols Sets a request for the given subprotocols.
Builds a new WebSocket connection from a request object and returns a future connection.

Arguments:

- `uri` a websocket uri
- `opts` (optional), a map of:
  - `:http-client` An HttpClient - will use a default HttpClient if not provided
  - `:listener` A WebSocket$Listener - alternatively will be created from the handlers passed into opts:
                :on-open, :on-message, :on-ping, :on-pong, :on-close, :on-error
  - `:headers` Adds the given name-value pair to the list of additional
               HTTP headers sent during the opening handshake.
  - `:connect-timeout` Sets a timeout for establishing a WebSocket connection (in millis).
  - `:subprotocols` Sets a request for the given subprotocols.
sourceraw docstring

websocket*clj

(websocket* {:keys [uri listener http-client headers connect-timeout
                    subprotocols]
             :as opts})

Same as websocket but take all arguments as a single map

Same as `websocket` but take all arguments as a single map
sourceraw docstring

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

× close