 (defn shutdown-send-queue [tal-state]
   (remove-watch (:send-queue @tal-state) ::send-watcher))
 
-
-;; XXX: handle callbacks and timeouts
 ;; XXX: handle special messages from the server (ping, close)
 (defn consume-recv-queue [tal-state handler]
   (let [recv-queue (:recv-queue @tal-state)]

    (gevents/listen w goog.net.WebSocket.EventType.MESSAGE
                    #(do
                       ;;(utils/mlog "message" %)
                       (swap! tal-state assoc :last-message-time (js/Date.))
                       (swap! recv-queue (fn [q] (apply conj q (decode-msg (.-message %)))))))
    (.open w url)
    tal-state))

    (loop [msg (pop-atom send-queue)]
      (when msg
        (send-msg ws msg)
        (swap! tal-state assoc :last-send-time (js/Date.))
        (recur (pop-atom send-queue))))))

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