       (when-not channel-open?
         (swap! connections dissoc chan-id)))))
 
-
-(defn dev-socket-helpers
-  "Dev functions for easy access to atom state
-
-  If running cider, use C-x C-e to eval the helper functions"
-  []
-
-  ;; Print number of connections
-  (prn (count (keys @connections)))
-
-  ;; Print connections
-  (clojure.pprint/pprint @connections)
-
-  ;; Remove all closed connections
-  (clean-connections 0)
-  )
-
 (defn connection-clean-err
   "If the scheduler fails this will be called
 

  [datomic]
  (fn [{:keys [chan-id] :as socket-user}
      {:keys [game-id]}]
    ;; TODO Check for ghost connections
    (swap! game-rooms assoc-in [game-id :players chan-id] socket-user)))

(defn- broadcast-game-message

  [error]
  (prn error))

(defn start-connection-cleanup
  "Kicks off the cleanup job responsible for removing closed channels
  from state."
  []
  (chime-at
   (rest (p/periodic-seq (t/now) (-> 10 t/seconds)))
   clean-connections
   {:error-handler connection-clean-err}))

(start-connection-cleanup)

(defn dev-socket-helpers
  "Dev functions for easy access to atom state

  If running cider, use C-x C-e to eval the helper functions"
  []

  ;; Print number of connections
  (prn (count (keys @connections)))

  ;; Print connections
  (clojure.pprint/pprint @connections)

  ;; Remove all closed connections
  (clean-connections 0)
  )

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helpers
