Skip to content

Instantly share code, notes, and snippets.

@schmee
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmee/7128ad47b35576187e86 to your computer and use it in GitHub Desktop.
Save schmee/7128ad47b35576187e86 to your computer and use it in GitHub Desktop.
(defn msg-loop [socket user running]
(when running
(println "running?" running)
(let [msg (read-line)]
(when (= msg "quit")
(println "disconnecting user" user)
(zend socket (str {:type :quit}))
(msg-loop socket user false))
(zend socket (str {:type :msg :user user :msg msg}))
(recur socket user true))))
(defn join [user]
(with-open [socket (Socket. "localhost" 8888)]
(register socket user)
(println "waiting for input")
(msg-loop socket user true)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment