 (defn send-for-eval [connections js]
   (let [prom (promise)]
     (doseq [[channel channel-data] connections]
-      (let [uuid (java.util.UUID/randomUUID)
+      (let [uuid (str (java.util.UUID/randomUUID))
             listener (fn listen [msg]
                        (when (= uuid (:uuid msg))
-                         (when-let [result (:result msg)]
+                         (when-let [result (:response msg)]
                            (deliver prom (vary-meta
                                           result
                                           assoc ::message msg)))
                          (remove-listener listen)))]
         (add-listener listener)
-        (hkit/send!
+        (hkit/send! ;; if we abstract this we can use other servers
          channel
          (json/write-str {:uuid uuid
                           :session-name (:session-name channel-data)


           (def state (atom {}))
           (def storage (storage-factory/createHTML5SessionStorage "figwheel.repl"))

           (defmulti message :op)
           (defmethod message "naming" [msg]
             (.set storage (str ::session-name) (:session-name msg)))

           (defn connect [websocket-url]
             (doto (goog.net.WebSocket.)
               (.addEventListener goog.net.WebSocket.EventType.MESSAGE
                                  (fn [e]
                                    (when-let [msg (gobj/get e "message")]
                                      (try
                                        (prn msg)
                                        (message (js->clj (js/JSON.parse msg) :keywordize-keys true))
                                        (catch js/Error e
                                          (js/console.error e))))))
               (.addEventListener goog.net.WebSocket.EventType.OPENED
                                  (fn [e]
                                    (js/console.log "OPENED")
                                    (js/console.log e)))
               (.open websocket-url)
               ))
           (js/console.log (.get storage (str ::session-name)))
           (js/console.log (nil? (.get storage (str ::session-name))))
           (connect (str "ws://localhost:9500/fargot" (when-let [n (.get storage (str ::session-name))]

(ns figwheel.repl
  (:require
   [clojure.string :as string]
   #?@(:cljs [[goog.object :as gobj]
              [goog.storage.mechanism.mechanismfactory :as storage-factory]
              [goog.userAgent.product :as product]]
       :clj [[clojure.data.json :as json]
             [clojure.set :as set]
             [clojure.edn :as edn]
