(abort! ws)Closes this WebSocket's input and output abruptly.
Closes this WebSocket's input and output abruptly.
(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.
(ping! ws data)Sends a Ping message with bytes from the given buffer.
Sends a Ping message with bytes from the given buffer.
(pong! ws data)Sends a Pong message with bytes from the given buffer.
Sends a Pong message with bytes from the given buffer.
(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.
(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
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! data last? ws)(websocket uri opts)Builds a new WebSocket connection from a request object and returns a future connection.
Arguments:
uri a websocket uriopts (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.(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
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |