Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created May 21, 2012 09:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neotyk/2761440 to your computer and use it in GitHub Desktop.
Save neotyk/2761440 to your computer and use it in GitHub Desktop.
WebSocket with http.async.client sample
(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