Created
February 13, 2018 15:25
-
-
Save shilder/39966c25daaba51d2d122d6acd8e51a4 to your computer and use it in GitHub Desktop.
Aleph websocket simplest client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[aleph.http :as http]) | |
(require '[manifold.stream :as s]) | |
(require '[manifold.deferred :as d]) | |
;; connection will hold duplex stream | |
;; deref will block while client is connecting | |
(defonce connection @(http/websocket-client "wss://url/")) | |
;; calls provided callback with every message on websocket | |
(s/consume | |
(fn [e] | |
(println e)) | |
connection) | |
;; sends data to websocket | |
(s/put! connection | |
"test string") | |
;; closes connection | |
(s/close! connection) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment