 (defmulti user-msg :op)
 
 (defmethod user-msg :default [msg]
-  (infof "ERROR: unknown user message %s" msg)
-  #_(srv/send-msg
-     (msg :ws) {:op "error" :payload "ERROR: unknown user message"}))
+  (let [params (msg :params)
+        {:keys [ws user eid action]} params]
+    (infof "ERROR: unknown user message %s" msg)
+    (send-end-msg
+     ws {:op :error
+         :payload (format "unknown user-msg '%s'" (msg :op))})))
 
 
 (defmethod user-msg :status [msg]
   (let [params (msg :params)
         {:keys [ws user eid action]} params]
+    #_(infof "STATUS %s" params)
     (let [jinfo (hc/get-db (atom (valuefy @job-db)) [user eid action])
           result (if (seq jinfo)
                    (->> jinfo (sort-by #(-> % :request :timestamp))

                                         (with-out-str (pprint status)))
                                        (format
                                         "Finished:\n%s\nFinal result:\n%s"
                                         (with-out-str (pprint status))
                                         (with-out-str (pprint res))))]
                             (with-out-str
                               (print (format "%s : %s started @ %s\n%s"
                                              eid action timestamp rstg))))
                          result)))]
      (send-end-msg ws {:op :status :payload retmsg}))))


(defmethod user-msg :run [msg]

   (fn[v]
     (cond
       (isa? (type v) clojure.lang.Atom) (recur (deref v))
       (isa? (type v) clojure.core.async.impl.channels.ManyToManyChannel) :chan
       (coll? v) (valuefy v)
       (not (future? v)) v
       (future-done? v) (deref v)
