Browse files

Towards using interpreting client commands

  • Loading branch information...
1 parent 52252c8 commit e4c42841ccd3a9d903879d7b45e50e63c45f1498 @apauley committed Dec 16, 2009
View
18 PeepCode/Clojure/mire/src/echo-server.clj
@@ -1,18 +0,0 @@
-(ns mire
- (:use [clojure.contrib server-socket duck-streams]))
-
-(def port 3333)
-
-(defn mire-handle-client [in out]
- (binding [*in* (reader in) ; Re-assign stdin and stdout
- *out* (writer out)]
- (loop []
- (print "You typed: ")
- (println (read-line))
- (recur))))
-
-(def server (create-server port mire-handle-client))
-
-(comment
- (close-server server)
-)
View
27 PeepCode/Clojure/mire/src/mire.clj
@@ -0,0 +1,27 @@
+(ns mire
+ (:use [mire commands])
+ (:use [clojure.contrib server-socket duck-streams]))
+
+(def port 3333)
+
+(defn- print-prompt []
+ (println)
+ (print "> ")
+ (flush))
+
+(defn- mire-handle-client [in out]
+ "Private function to handle client requests"
+
+ (binding [*in* (reader in) ; Re-assign stdin and stdout
+ *out* (writer out)]
+ (print-prompt)
+ (loop [input (read-line)]
+ (println input)
+ (print-prompt)
+ (recur (read-line)))))
+
+(def server (create-server port mire-handle-client))
+
+(comment
+ (close-server server)
+)
View
0 PeepCode/Clojure/mire/src/mire/commands.clj
No changes.

0 comments on commit e4c4284

Please sign in to comment.