                   :mouse-up {:ch mouse-up-ch
                              :mult (async/mult mouse-up-ch)}})))
 
+(defn controls-handler
+  [value state container]
+  (when true (:log-channels? utils/initial-query-map)
+        (mlog "Controls Verbose: " value))
+  (swallow-errors
+   (let [previous-state @state]
+     (swap! state (partial controls-con/control-event container (first value) (second value)))
+     (controls-pcon/post-control-event! container (first value) (second value) previous-state @state))))
+
+(defn nav-handler
+  [value state history]
+  (when true (:log-channels? utils/initial-query-map)
+        (mlog "Navigation Verbose: " value))
+  (swallow-errors
+   (let [previous-state @state]
+     (swap! state (partial nav-con/navigated-to history (first value) (second value)))
+     (nav-pcon/post-navigated-to! history (first value) (second value) previous-state @state))))
+  
+(defn api-handler
+  [value state container]
+  (when true (:log-channels? utils/initial-query-map)
+        (mlog "API Verbose: " (first value) (second value) (utils/third value)))
+  (swallow-errors
+    (let [previous-state @state]
+      (swap! state (partial api-con/api-event container (first value) (second value) (utils/third value)))
+      (api-pcon/post-api-event! container (first value) (second value) (utils/third value) previous-state @state))))
+
+(defn ws-handler
+  [value state pusher]
+  (when true (:log-channels? utils/initial-query-map)
+        (mlog "websocket Verbose: " (pr-str (first value)) (second value) (utils/third value)))
+  (swallow-errors
+    (let [previous-state @state]
+      ;; XXX: should these take the container like the rest of the controllers?
+      (swap! state (partial ws-con/ws-event pusher (first value) (second value)))
+      (ws-pcon/post-ws-event! pusher (first value) (second value) previous-state @state))))
+
 (defn main [state top-level-node]
   (let [comms       (:comms @state)
         target-name "app"

            [frontend.utils :as utils :refer [mlog merror third]]
            [secretary.core :as sec])
  (:require-macros [cljs.core.async.macros :as am :refer [go go-loop alt!]]
                   [frontend.utils :refer [inspect timing]])
  (:use-macros [dommy.macros :only [node sel sel1]]))

(enable-console-print!)

      :opts {:comms comms}})
    (go (while true
          (alt!
           (:controls comms) #(controls-handler % state container)
           (:nav comms) #(nav-handler % state history-imp)
           (:api comms) #(api-handler % state container)
           (:ws comms) #(ws-handler % state pusher-imp)
           ;; Capture the current history for playback in the absence
           ;; of a server to store it
           (async/timeout 10000) (do (print "TODO: print out history: ")))))))
