    :onyx.peer/job-scheduler :onyx.job-scheduler/round-robin 
    :onyx/id :SUPPLY_ME})
 
-(comment (reset! replica-state nil)
-         (deref replica-state)
-         (clojure.pprint/pprint {:orig orig :new new}))
+(defn zk-deployment-entry-stat [client entry]
+  (:stat (zk/data client (zk-onyx/prefix-path entry))))
+
+(def deployments (atom {}))
+(def tracking (atom {}))
+
+(defn distribute-deployments [send-all-fn! deployments]
+  (send-all-fn! [:deployment/listing deployments]))
+
+(defn refresh-deployments-watch [send-all-fn! zk-client]
+  (->> (zk/children zk-client zk-onyx/root-path :watcher (fn [_] (refresh-deployments-watch send-all-fn! zk-client)))
+       (map (juxt identity 
+                  (partial zk-deployment-entry-stat zk-client)))
+       (map (fn [[child stat]]
+              (vector child
+                      {:created (java.util.Date. (:ctime stat))
+                       :modified (java.util.Date. (:mtime stat))})))
+       (into {})
+       (reset! deployments)
+       (distribute-deployments send-all-fn!)))
 
 (defn event->uid [event]
   (get-in event [:ring-req :cookies "ring-session" :value]))
 
-(def tracking (atom {}))
-
 (defn launch-event-handler [sente peer-config]
   (thread
     (loop []
-      (let [[event _] (alts!! [(:ch-chsk sente) 
-                               #_(:ring-ajax-get-or-ws-handshake sente)])]
-        (when event
-          (info "EVENT:" event)
-          ;; TODO: more sophisticated tracking,
-          ;; should track by cluster id rather than user
-          ;; and count the number of users tracking it. When the user count drops to 0
-          ;; then stop the future.
+      (when-let [event (<!! (:ch-chsk sente))]
+        (info "EVENT:" event)
+        ;; TODO: more sophisticated tracking,
+        ;; should track by cluster id rather than user
+        ;; and count the number of users tracking it. When the user count drops to 0
+        ;; then stop the future.
+        (let [user-id (event->uid event)] 
           (case (:id event) 
-            :cluster/track (let [user-id (event->uid event)] 
-                             (swap! tracking 
-                                    assoc 
-                                    user-id
-                                    (future (track-cluster sente 
-                                                           (assoc env-conf :onyx/id (:?data event)) 
-                                                           user-id))))
-            :chsk/uidport-close (let [user-id (event->uid event)] 
+            :deployment/track (do (when-let [fut (@tracking user-id)]
+                                    (future-cancel fut))
+                                  (swap! tracking 
+                                         assoc 
+                                         user-id
+                                         (future (track-deployment (:chsk-send! sente)
+                                                                   (assoc env-conf :onyx/id (:?data event)) 
+                                                                   user-id))))
+            :deployment/get-listing ((:chsk-send! sente) user-id [:deployment/listing @deployments])
+            :chsk/uidport-close (do
                                   (future-cancel (@tracking user-id))
                                   (swap! tracking dissoc user-id)) 
-            (println "Dunno what to do with: " event))
-          (recur))))))
+            (println "Dunno what to do with: " event)))
+        (recur)))))
 
+(defn send-mult-fn [send-fn! connected-uids msg]
+  (doseq [uid (:any @connected-uids)]
+    (send-fn! uid msg)))
+
+; no need for env-config and peer-config
 (defrecord HttpServer [peer-config]
   component/Lifecycle
   (start [{:keys [sente] :as component}]

            entry (extensions/read-log-entry (:log client) position)
            new-replica (extensions/apply-log-entry entry replica)
            diff (extensions/replica-diff entry replica new-replica)]
        ((:chsk-send! sente) uid [:cluster/replica {:replica new-replica
                                                    :diff diff}])
        (recur new-replica)))))

(def env-conf


(def replica-state (atom {:replica nil :diff nil}))

(defn track-deployment [send-fn! peer-config uid]
  (let [ch (chan 100)
        client (component/start (system/onyx-client peer-config))]
    (loop [replica (extensions/subscribe-to-log (:log client) ch)]
