 (def listeners (atom {}))
 (def clients (atom {}))
 
-(def last-status (atom nil))
-(defn save-last-status!
-  [status]
-  (reset! last-status status))
-
+(def last-actions (atom {}))
+(defn save-last-action!
+  [action]
+  (swap! last-actions merge action))
 
 (defn tell!
   [who what]

      (fn [data]
        (tell! clients data)
        (with-mongo db (insert! :actions data))
        (doseq [[k v] data]
          (case k
            "tab-changed" (save-last-status! data)
            "screenshot"  (spit "/Users/chetan/Desktop/screenshot.jpg" v))))))
  (GET "/" []
  	(clojure.java.io/resource "public/index.html"))
  (route/resources "/")

    (web-socket-handler
      clients
      (fn []
        (tell! clients @last-actions))
      (fn [data]
        (tell! listeners data)
        (with-mongo db (insert! :comments data)))))
