 (def sample-translation {:topic "German" :language "German" :content "Guten Tag"
                          :original-sha "XYZ" :content-sha "ABC" :user-name "bob"})
 
+(def sample-users ["Eric" "Colin" "Brian" "Rick"])
+
 (def app-state (atom {:original [sample-source]
-                      :translated [sample-translation]}))
+                      :translated [sample-translation]
+                      :users sample-users}))
+
+(defn handle-incoming [listener-ch server-ch]
+  (go
+   (loop []
+     (when-let [msg (<! server-ch)]
+       (do (>! listener-ch msg)
+           (recur))))))
+
+(defn handle-outgoing [sender-ch server-ch]
+  (go
+   (loop []
+     (when-let [msg (<! sender-ch)]
+       (>! server-ch msg)
+       (recur)))))
+
+(defn make-socket [listener-ch sender-ch]
+  (go
+   (let [{:keys [ws-channel error]} (<! (ws-ch +ws-url+))]
+     (when ws-channel
+       (do
+         (handle-incoming listener-ch ws-channel)
+         (handle-outgoing sender-ch ws-channel))))))
+
+(defn clear-text [owner]
+  (om/set-state! owner :text ""))
+
+(defn post-message [target text]
+  (println text)
+  #_(put! target text)
+  false)
+
+(defn check-for-enter [e owner {:keys [text sender-ch]}]
+  (when (or (= 13 (.-keyCode e))
+            (= 13 (.-which e)))
+    (do
+      (post-message sender-ch text)
+      clear-text owner)))
+
+(defn text-entry [e owner {:keys [text]}]
+  (om/set-state! owner :text (.. e -target -value)))
+
+(defn users-view [app owner]
+  (reify
+    om/IRender
+    (render [this]
+      (apply dom/ul nil
+             (map (fn [item] (dom/li nil item)) app)))))
 
 (defn chat-view [app owner]
   (reify


(defn master-view [app owner]
  (reify
    om/IRender
    (render [this]
      (dom/div #js {:className "container"}
               (dom/h3 nil "Enter Chat stuff")
               (dom/form #js {:className "form-horizontal"}
                         (dom/div nil
                                  (dom/div nil
                                           (om/build chat-view (:original app)))
                                  (dom/div nil
                                           (om/build chat-view (:translated app))))
                         (dom/div #js {:className "form-group"}
                                  (dom/input #js {:className "form-control" :type "text"}))
                         (dom/div #js {:className "col-xs-offset-2 col-xs-10"}
                                  (dom/button #js {:type "button" :className "button"}
                                              "click me")))))))

(om/root

  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [chord.client :refer [ws-ch]]
            [cljs.core.async :refer [chan <! >! put!] :as a]
            [sablono.core :as html :refer-macros [html]])
  (:require-macros [cljs.core.async.macros :refer [go]]))

