 (defn cmd-gets-keys [decoded]
   (extract-cmd-args decoded (fn [v] v)))
 
-(defn handle [ch ci cmd]
+(defn debug-response [ch msg r]
+  (do 
+    (println msg r)
+    (map #(enqueue ch %) r)))
+
+(defn test-handle [ch ci cmd]
     (println "Processing command: " (first cmd) " from " ci)
     (condp = (first cmd)
-      "SET" (do (println "doing enqueue put") (enqueue ch ["STORED"]))
-      "GET" (enqueue ch "got get\r\n")
-      "GETS" (enqueue ch "got mget\r\n")
+      "SET" (enqueue ch ["STORED"]) 
+      "GET" (do (enqueue ch ["VALUE" "abc" "123"]) (enqueue ch ["END"]))
+      "GETS" (do (enqueue ch ["VALUE" "abc" "123"]) (enqueue ch ["END"]))
       (enqueue ch "error")))
 
 
 (defn handler
   [ch ci]
-  (receive-all ch (partial handle ch ci)))
+  (receive-all ch (partial test-handle ch ci)))
 
 
 ;(def s (start-tcp-server handler {:port 10000 :frame CMDS}))

(def TRM-DATA-BLOCK (string :utf-8 :suffix "\r\n"))
(def C (string :utf-8 :delimiters " "))
(def K (string :utf-8 :delimiters " "))
(def CR (string :utf-8 :delimiters ["\r\n"]))

(defcodec SET ["SET" CR])
(defcodec STORED ["STORED" CR])
;STORED\r\n

(defcodec GET ["GET" CR])
(defcodec GETS ["GETS" CR])
(defcodec END ["END" CR])
(defcodec VALUE [C CR CR])

; to test (decode GET-REPLY gets_test_b)
(defcodec GET-REPLY (repeated VALUE :prefix :none :delimiters ["END\r\n"]))

;VALUE <key> <flags> <bytes> [<cas unique>]\r\n
;<data block>\r\n

(defcodec CMDS
          (header C
                  (fn [h]
                    (println "processing " h)
                    (case h
                      "SET" SET
                      "GET" GET
                      "GETS" GETS
                      "STORED" (do (println "do stored") STORED)
                      "VALUE" (do (println "do value") VALUE)
                      "END" END
                      (do (println "err") ERRC)))
                  first))

