Created
May 21, 2012 09:18
-
-
Save neotyk/2761440 to your computer and use it in GitHub Desktop.
WebSocket with http.async.client sample
This file contains hidden or 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 '[http.async.client :as http]) | |
;; create clients | |
(def client (http/create-client)) | |
;; websocket | |
(let [latch (promise) | |
ws (http/websocket | |
client "ws://localhost:8108/socket" | |
;; text message callback | |
:text (fn [msg] | |
(println msg) | |
(deliver latch true)))] | |
(println "sending") | |
(http/send ws :text "testing12") | |
(println "sent") | |
@latch | |
(http/close ws) | |
(println "closed")) | |
;; close client | |
(http/close c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment