                        (send! wschannel (prn-str msg)))))))
     
     (on-close wschannel (fn [status]
+                          (swap! connection-count dec)
                           (remove-watch file-change-atom watch-key)
-                          (println "Figwheel: client disconnected " status)))
+                          #_(println "Figwheel: client disconnected " status)))
 
     (on-receive wschannel (fn [data] (handle-client-msg server-state data)))
 

                       { :msg-name msg-name 
                         :project-id (:unique-id opts)})))

(defn setup-file-change-sender [{:keys [file-change-atom compile-wait-time] :as server-state}
                                wschannel]
  (let [watch-key (keyword (gensym "message-watch-"))]
    (add-watch file-change-atom
               watch-key
               (fn [_ _ o n]

      ["emacsclient" "-n" (str "+" file-line) file-name] ;; we are emacs aware
      [open-file-command file-name file-line])))

(defn handle-client-msg [{:keys [browser-callbacks] :as server-state} data]
  (when data
    (let [msg (read-msg data)]
      (if (= "callback" (:figwheel-event msg))
        (when-let [cb (get @browser-callbacks (:callback-name msg))]
          (cb (:content msg)))
        (when-let [command (and (= "file-selected" (:figwheel-event msg))
                                (get-open-file-command server-state msg))]
          (try
            (.exec (Runtime/getRuntime) (into-array String command))
            (catch Exception e
              (println "Figwheel: there was a problem running the open file command - " command))))))))

(defn add-build-id [{:keys [build-id]} msg]
  (if build-id
