(connect! uri)
(connect! uri
{:keys [in-buf-or-n out-buf-or-n in-xform out-xform subprotocols
on-connect]
:or {on-connect (constantly nil)}})
Wraps the ws-client-cljs.client/IWebSocket with a core.async channel uri - a URI such as ws://example.com/ws in-buf-or-n - the buf-or-n arg used for creating the channel of messages from the server out-buf-or-n - the buf-or-n arg used for creating the channel of messages to be send to the server in-xform - the transducer applied to all messages coming from the server out-xform - the transducer applied to all messages being sent to the server subprotocols - a seq of protocols (strings) to be sent with the handshake request
Example: (def ws (ws/connect! "ws://example.com/ws" {:in-buf-or-n 10 :out-buf-or-n 10 :in-xform (map clojure.edn/read-string) :out-xform (map pr-str) :subprotocols ["protocol-1" "protocol-2"]})) (async/>!! ws {:message "PING"}) (println (async/<!! ws)) (async/close! ws)
Wraps the ws-client-cljs.client/IWebSocket with a core.async channel uri - a URI such as ws://example.com/ws in-buf-or-n - the buf-or-n arg used for creating the channel of messages from the server out-buf-or-n - the buf-or-n arg used for creating the channel of messages to be send to the server in-xform - the transducer applied to all messages coming from the server out-xform - the transducer applied to all messages being sent to the server subprotocols - a seq of protocols (strings) to be sent with the handshake request Example: (def ws (ws/connect! "ws://example.com/ws" {:in-buf-or-n 10 :out-buf-or-n 10 :in-xform (map clojure.edn/read-string) :out-xform (map pr-str) :subprotocols ["protocol-1" "protocol-2"]})) (async/>!! ws {:message "PING"}) (println (async/<!! ws)) (async/close! ws)
(keep-alive! uri)
(keep-alive! uri
{:keys [in-buf-or-n out-buf-or-n in-xform out-xform subprotocols
reconnect-ms on-connect]
:or {reconnect-ms RECONNECT_TIMEOUT on-connect (constantly nil)}})
Wraps the ws-client-cljs.client/IWebSocket with a core.async channel and continuously tries to keep a connection
unless the channel is manually closed with clojure.core.async/close!
.
uri - a URI such as ws://example.com/ws
in-buf-or-n - the buf-or-n arg used for creating the channel of messages from the server
out-buf-or-n - the buf-or-n arg used for creating the channel of messages to be send to the server
in-xform - the transducer applied to all messages coming from the server
out-xform - the transducer applied to all messages being sent to the server
subprotocols - a seq of protocols (strings) to be sent with the handshake request
Example: (def ws (ws/keep-alive! "ws://example.com/ws" {:in-buf-or-n 10 :out-buf-or-n 100 :in-xform (map clojure.edn/read-string) :out-xform (map pr-str) :subprotocols ["protocol-1" "protocol-2"]})) (async/>!! ws {:message "PING"}) (println (async/<!! ws)) (async/close! ws) ;; Discontinues "keep alive" behavior.
Wraps the ws-client-cljs.client/IWebSocket with a core.async channel and continuously tries to keep a connection unless the channel is manually closed with `clojure.core.async/close!`. uri - a URI such as ws://example.com/ws in-buf-or-n - the buf-or-n arg used for creating the channel of messages from the server out-buf-or-n - the buf-or-n arg used for creating the channel of messages to be send to the server in-xform - the transducer applied to all messages coming from the server out-xform - the transducer applied to all messages being sent to the server subprotocols - a seq of protocols (strings) to be sent with the handshake request Example: (def ws (ws/keep-alive! "ws://example.com/ws" {:in-buf-or-n 10 :out-buf-or-n 100 :in-xform (map clojure.edn/read-string) :out-xform (map pr-str) :subprotocols ["protocol-1" "protocol-2"]})) (async/>!! ws {:message "PING"}) (println (async/<!! ws)) (async/close! ws) ;; Discontinues "keep alive" behavior.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close