I had some issues using the example as the websocket, it was connecting fine, but it did not appear to be handling messages. It looks to me like this example should also include :text
Looking at the code in websocket.clj it does appear to have two distinct methods for handing char vs byte, create-text-listener and create-byte-listener
I just re-used handle-message, added in :text handle-message
eg: (existing)
(defn -main []
(println "Connecting...")
(with-open [client (http/create-client)]
(let [ws (http/websocket client
url
:open on-open
:close on-close
:error on-error
:byte handle-message)]
; this loop-recur is here as a placeholder to keep the process
; from ending, so that the message-handling function will continue to
; print messages to STDOUT until Ctrl-C is pressed
(loop [] (recur)))))
(defn -main []
(println "Connecting...")
(with-open [client (http/create-client)]
(let [ws (http/websocket client
url
:open on-open
:close on-close
:error on-error
:byte handle-message
:text handle-message)]
; this loop-recur is here as a placeholder to keep the process
; from ending, so that the message-handling function will continue to
; print messages to STDOUT until Ctrl-C is pressed
(loop [] (recur)))))
Perhaps a newbie issue, but might help others..
I had some issues using the example as the websocket, it was connecting fine, but it did not appear to be handling messages. It looks to me like this example should also include :text
Looking at the code in websocket.clj it does appear to have two distinct methods for handing char vs byte, create-text-listener and create-byte-listener
I just re-used handle-message, added in :text handle-message
eg: (existing)