 (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]

    (stop-f :timeout 100)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Application

(defn stop! []
  (do
    (stop-http-server!)
    (stop-router!)))

(defn start! []
  (do
    (start-http-server!)
    (start-router!)))

(defn -main
  [& args]

  (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
