     app-state
     {:target (. js/document (getElementById "app"))}))
 
-;; (set! (.-title js/document) "uf")
-;; (.log js/console (.-title js/document))
-
-(defn on-message [event]
-  (.log js/console event))
-
 (defn s4 []
   (let [r (+ 1 (Math/random))
         r2 (* r 0x10000)

(defn guid "Generates a random GUID" []
  (str (s4) (s4) "-" (s4) "-" (s4) "-" (s4) "-" (s4) (s4) (s4)))

(defn ^:export init []
  (let [url "ws://localhost:9000/api/ws"
        socket (js/WebSocket. url)]
    (set! (.-onopen socket) #(log %))
    (set! (.-onmessage socket) on-message)
    socket))


(defn log [& args]
  (.apply (.-log js/console) js/console (clj->js args)))

(let [c (chan)]
  (put! c "hello")
  (go (log (<! c))))

(defn send [socket]
  (let [params {:api_key "foo"
                :user (guid)
                :action "identify"
                :data {}
                :id (guid)
                :timestamp (.getTime (js/Date.))}
        json (clj->js params)
        json-str (.stringify js/JSON json)]
    (.send socket json-str)))

  (:require-macros [cljs.core.async.macros :refer [go]]))

(defonce app-state (atom {:text "Hello Chestnut!"}))

(defn log [& args]
  (.apply (.-log js/console) js/console (clj->js args)))

(defn stringify [msg] (.stringify js/JSON (clj->js msg)))

(defn main []
  (om/root
