Started playing with getting an within emacs clojure-based mud client, but puzzling a bit with parsing the incoming stream. The below works (for emacs+swank-clojure 1.4.0), but puts a space between every character. When I try to solve that (for example by swapping "(print ..." with "(print (apply str ...", then incoming text is no longer automatically parsed into the repl.
Anyone knows how to fix this? (use 'swank.core) ;; 1.4.0-MASTER (import (org.apache.commons.net.telnet Telnet TelnetClient TelnetOutputStream)) (defn connect [] (let [client (TelnetClient.)] (.connect client (java.net.InetAddress/getByName "avendar.com") 9999) client)) (declare send-to-mud) (defn start-reading [session] (with-read-line-support (send-to-mud session (read-line)))) (defn send-to-mud [session message] (.write (.getOutputStream session) (.getBytes message)) (.flush (.getOutputStream session)) (start-reading session)) ;; Connect to mud ;;;;;;;;;;;;;; (def avendar (connect)) (print (take 10000 (remove #{\return} (map char (take-while #(not= % -1) (repeatedly #(.read (.getInputStream avendar)))))))) ;; Type this in repl: ;;;;;;;;;;;;;; (start-reading avendar) ;; Eval this to disconnect: ;;;;;;;;;;;;;; (.disconnect avendar) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en