                               :closed? true
                               :close-code (.-code %)
                               :close-reason (.-reason %))
+                       (js/clearInterval (:keep-alive-timer @tal-state))
                        (when (fn? on-close)
                          (on-close tal-state {:code (.-code %)
                                               :reason (.-reason %)}))))

    (loop [msg (pop-atom send-queue)]
      (when msg
        (send-msg ws msg)
        (recur (pop-atom send-queue))))))

(defn start-send-queue [tal-state]

(defn shutdown-send-queue [tal-state]
  (remove-watch (:send-queue @tal-state) ::send-watcher))

;; XXX: handle special messages from the server (ping, close)
(defn consume-recv-queue [tal-state handler]
  (let [recv-queue (:recv-queue @tal-state)]
