             [clojure.core.async
              :as a
              :refer [>! <! >!! <!! go chan buffer close! thread
-                     alts! alts!! timeout]]
-            ))
+                     alts! alts!! timeout go-loop]]))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Resources
+;http://www.core-async.info/tutorial/a-minimal-client
+;https://github.com/enterlab/rente
+
+; http://localhost:1337/admin
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (def memory-log (atom []))
 

(defn import-file [{:keys [content]}]
  (imp/dance-perfect-xml->data (imp/read-xml-string content)))

(def message-chan (chan))
(def message-send-chan (chan))

;; (go (println (<! test-chan)))
;; (>!! test-chan "Duudde")

(def message-log (atom []))
(def message-send-log (atom []))

(go (while true
      (let [msg (<! message-chan)]
        (swap! message-log conj msg)
        (message-dispatch msg message-send-chan))))

(go (while true
      (let [msg (<! message-send-chan)]
        (swap! message-send-log conj msg)
        (chsk-send! (:id msg) (:message msg)))))


(defn message-dispatch [{:keys [topic payload sender]} out-chan]
  (match [topic payload]

  (def connected-uids                connected-uids) ; Watchable, read-only atom
  )

(defn event-msg-handler* [messages-receive-chan {:as ev-msg :keys [id ?data event ring-req]}]
  (>!! messages-receive-chan {:topic id :payload ?data :sender (:uid (:session ring-req))}))

(defonce router_ (atom nil))

(defn stop-router! []
  (when-let [stop-f @router_] (stop-f)))

(defn start-router! [messages-receive-chan]
  (stop-router!)
  (reset! router_ (sente/start-chsk-router! ch-chsk (partial event-msg-handler* messages-receive-chan))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Http routing
