我有一个构造websocket客户端的代码
(require '[aleph.http :as http]
'[manifold.stream :as stream]
'[cheshire.core :as json])
(def raw (deref (http/websocket-client url)))
和数据通道:
(def data (stream/stream))
原始通道返回可以来回转换的字节:
(defn to-data [bytes]
(-> bytes
(String.)
(json/parse-string)))
(defn to-raw [data]
(-> data
json/generate-string
(.getBytes)))
我希望连接原始数据和数据,以便进行双向转换,以保持数据格式的一致性。
raw| == [to-data] ==> |data
| <== [to-raw] == |
有一种称为“连接通过”的方法。但我不确定它是如何使用的