            (msg-fn msg)
            (js/setTimeout #(poll msg-fn connect-url') 500))
          (fn [e] ;; lost connection
+           (connection-closed! connect-url')
            (http-connect connect-url'))))
 
 (defn long-poll [msg-fn connect-url']

                               (connection-established! url)
                               (swap! state assoc :connection {:websocket websocket})
                               (hook-repl-printing-output! {:websocket websocket})))
          (.open url))))))

;; -----------------------------------------------------------

           (doto (js/Event. "figwheel.repl.connected" target)
             (gobj/add "data" {:url url}))))))

(defn connection-closed! [url]
  (when (= host-env :html)
    (let [target (.. goog.global -document -body)]
      (.dispatchEvent
       target
       (doto (js/Event. "figwheel.repl.disconnected" target)
         (gobj/add "data" {:url url}))))))

(defn get-websocket-class []
  (or
   (gobj/get goog.global "WebSocket")
