(build-websocket uri listener-fns)
(build-websocket uri listener-fns builder-opts)
Builds a new WebSocket with the provided options.
uri
- The URI to connect tolistener-fns
- see websocket-listener
builder-opts
- see websocket-builder
Builds a new [WebSocket](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html) with the provided options. - `uri` - The URI to connect to - `listener-fns` - see [[websocket-listener]] - `builder-opts` - see [[websocket-builder]]
(build-websocket-async uri listener-fns)
(build-websocket-async uri listener-fns builder-opts)
Same as build-websocket
, but returns a CompletableFuture<WebSocket>
instead of WebSocket
.
Same as [[build-websocket]], but returns a `CompletableFuture<WebSocket>` instead of `WebSocket`.
(close ws)
(close ws status-code)
(close ws status-code reason)
Closes the output of the websocket with the supplied status code and reason. If not provided, status-code
defaults to 1000 (normal closure) and reason
defaults to empty string.
Equivalent to sendClose.
Closes the output of the websocket with the supplied status code and reason. If not provided, `status-code` defaults to 1000 (normal closure) and `reason` defaults to empty string. Equivalent to [sendClose](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html#sendClose%28int,java.lang.String%29).
(send ws payload)
(send ws payload last?)
Synchronously send data over the websocket and then returns the websocket. payload
can be any of:
Any other argument type will be coerced to a string with str
and sent with sendText.
last?
is a boolean that indicates whether this invocation completes the message. Defaults to true
.
Synchronously send data over the websocket and then returns the websocket. `payload` can be any of: - a string - sent with [sendText](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html#sendText%28java.lang.CharSequence,boolean%29) - a byte array - converted into a ByteBuffer and sent with [sendBinary](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html#sendBinary%28java.nio.ByteBuffer,boolean%29) - a ByteBufer - sent with [sendBinary](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html#sendBinary%28java.nio.ByteBuffer,boolean%29) Any other argument type will be coerced to a string with `str` and sent with [sendText](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.html#sendText%28java.lang.CharSequence,boolean%29). `last?` is a boolean that indicates whether this invocation completes the message. Defaults to `true`.
(send-async ws payload)
(send-async ws payload last?)
Same as send
, but returns a CompletableFuture<WebSocket>
instead of WebSocket
.
Same as [[send]], but returns a `CompletableFuture<WebSocket>` instead of `WebSocket`.
(websocket-builder)
(websocket-builder {:keys [client connect-timeout headers subprotocols]})
Builds a Websocket.Builder.
opts
is a map containing one of the following keywords:
:client
- the HttpClient to create the connect with, defaults to [[default-client]]:connect-timeout
- connection timeout in milliseconds or a java.time.Duration
:headers
- the HTTP headers, a map where keys are strings and values are strings or a list of strings:subprotocols
- a string sequence of subprotocols to use in order of preferencesBuilds a [Websocket.Builder](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Builder.html). `opts` is a map containing one of the following keywords: - `:client` - the [HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html) to create the connect with, defaults to [[default-client]] - `:connect-timeout` - connection timeout in milliseconds or a `java.time.Duration` - `:headers` - the HTTP headers, a map where keys are strings and values are strings or a list of strings - `:subprotocols` - a string sequence of subprotocols to use in order of preferences
(websocket-listener {:keys [on-binary on-close on-error on-open on-ping on-pong
on-text]})
Builds a Websocket.Listener.
listener-fns is a map of keyword to function:
:on-binary
- See onBinary. The data
argument is converted from a ByteBuffer
to a byte array before being passed to the function.:on-close
- See onClose:on-error
- See onError:on-open
- See onOpen:on-ping
- See onPing. The data
argument is converted from a ByteBuffer
to a byte array before being passed to the function.:on-pong
- See onPong. The data
argument is converted from a ByteBuffer
to a byte array before being passed to the function.:on-text
- See onText. The data
argument is converted from a CharSequence
to a string before being passed to the function.Builds a [Websocket.Listener](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html). listener-fns is a map of keyword to function: - `:on-binary` - See [onBinary](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onBinary%28java.net.http.WebSocket,java.nio.ByteBuffer,boolean%29). The `data` argument is converted from a `ByteBuffer` to a byte array before being passed to the function. - `:on-close` - See [onClose](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onClose%28java.net.http.WebSocket,int,java.lang.String%29) - `:on-error` - See [onError](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onError%28java.net.http.WebSocket,java.lang.Throwable%29) - `:on-open` - See [onOpen](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onOpen%28java.net.http.WebSocket%29) - `:on-ping` - See [onPing](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onPing%28java.net.http.WebSocket,java.nio.ByteBuffer%29). The `data` argument is converted from a `ByteBuffer` to a byte array before being passed to the function. - `:on-pong` - See [onPong](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onPong%28java.net.http.WebSocket,java.nio.ByteBuffer%29). The `data` argument is converted from a `ByteBuffer` to a byte array before being passed to the function. - `:on-text` - See [onText](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/WebSocket.Listener.html#onText%28java.net.http.WebSocket,java.lang.CharSequence,boolean%29). The `data` argument is converted from a `CharSequence` to a string before being passed to the function.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close