(ws-ch ws-url & [{:keys [read-ch write-ch format ws-opts] :as opts}])
Creates websockets connection and returns a 2-sided channel when the websocket is opened. Arguments: ws-url - (required) link to websocket service opts - (optional) map to configure reading/writing channels :read-ch - (optional) (possibly buffered) channel to use for reading the websocket :write-ch - (optional) (possibly buffered) channel to use for writing to the websocket :format - (optional) data format to use on the channel, (at the moment) either :edn (default), :json, :json-kw or :str. :ws-opts - (optional) Other options to be passed to the websocket constructor (NodeJS only) see https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketaddress-protocols-options
Usage: (:require [cljs.core.async :as a])
(a/<! (ws-ch "ws://127.0.0.1:6437"))
(a/<! (ws-ch "ws://127.0.0.1:6437" {:read-ch (a/chan (a/sliding-buffer 10))}))
(a/<! (ws-ch "ws://127.0.0.1:6437" {:read-ch (a/chan (a/sliding-buffer 10)) :write-ch (a/chan (a/dropping-buffer 10))}))
Creates websockets connection and returns a 2-sided channel when the websocket is opened. Arguments: ws-url - (required) link to websocket service opts - (optional) map to configure reading/writing channels :read-ch - (optional) (possibly buffered) channel to use for reading the websocket :write-ch - (optional) (possibly buffered) channel to use for writing to the websocket :format - (optional) data format to use on the channel, (at the moment) either :edn (default), :json, :json-kw or :str. :ws-opts - (optional) Other options to be passed to the websocket constructor (NodeJS only) see https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketaddress-protocols-options Usage: (:require [cljs.core.async :as a]) (a/<! (ws-ch "ws://127.0.0.1:6437")) (a/<! (ws-ch "ws://127.0.0.1:6437" {:read-ch (a/chan (a/sliding-buffer 10))})) (a/<! (ws-ch "ws://127.0.0.1:6437" {:read-ch (a/chan (a/sliding-buffer 10)) :write-ch (a/chan (a/dropping-buffer 10))}))
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close