   "Given the first item in the return value of `make-app` function,
   this function will unwatch the current open watches to the
   DirectoryReader. The app should not and cannot be used afterwards."
-  [{:keys [open channels] :as state}]
+  [{:keys [open channels sessions] :as state}]
   (info "Stopping the reader application ...")
   (reset! open false)
   (doseq [[sess-id topic-chans] @channels
           [topic _] topic-chans]
     (unsubscribe state sess-id topic))
-  (doseq [[sess-id _] @wamp/client-channels]
+  (doseq [sess-id @sessions]
     (wamp/close-channel sess-id))
   (info "Stopped the reader application."))
 

  for the `stop-app` function, and the second is the ring app
  function."
  [directory-reader & {:keys [subscribe-buffer] :as config}]
  (let [state (State. directory-reader config (atom {}) (atom nil) (atom true))
        app (make-app* state)]
    [state app]))


;;; Exposing a DirectoryReader as a Websocket service.

;; channels = (atom {"sess-id" {"topic" async.chan}})
;; sessions = (atom #{"sess-id"})
(defrecord State [dirreader config channels stop-fn open sessions])


(defn- unsubscribe
