could somebody enlighten me as to how I would use the callbacks for WebSocket send async? Specifically:
• if succeed does not have any arguments, how does it know would which send operation it is success for?
• similarly for fail
Yep, as hiredman says, use a closure. For example:
(defn send-greetings [socket name]
(ws/send socket (str "Hello " name)
(fn [] (println "Succeeded in greeting" name))
(fn [_ex] (println "Failed in greeting" name))))
There's also https://github.com/ring-clojure/ring-websocket-async, which allows you to use core.async for a more convenient way of writing async code.a closure can close over any needed state