     (info "CLIENT-CONNECT" url)
     (doto channel
       (events/listen goog.net.WebSocket.EventType.MESSAGE
-              (fn [evt]
-                (debug "receiving: " (-> evt .-message))
-                (put! in (with-meta (->> evt .-message (read-string-safe @tag-table))
-                           {:host host}))))
+                     (fn [evt]
+                       (debug "receiving: " (-> evt .-message))
+                       (let [reader (transit/reader :json)
+                             fr (js/FileReader.)]
+                         (set! (.-onload fr) #(transit/read reader (.-result fr)))
+                         (put! in (with-meta (.readAsText fr (.-message evt))
+                                    {:host host})))))
       (events/listen goog.net.WebSocket.EventType.CLOSED
-              (fn [evt] (close! in) (.close channel) (close! opener)))
+                     (fn [evt] (close! in) (.close channel) (close! opener)))
       (events/listen goog.net.WebSocket.EventType.OPENED
-              (fn [evt] (put! opener [in out]) (close! opener)))
+                     (fn [evt] (put! opener [in out]) (close! opener)))
       (events/listen goog.net.WebSocket.EventType.ERROR
-              (fn [evt] (error "ERROR:" evt) (close! opener)))
+                     (fn [evt] (error "ERROR:" evt) (close! opener)))
       (.open url))
-    ((fn sender [] (take! out
-                         (fn [m]
-                           (debug "sending: " m)
-                           (.send channel (str " " (pr-str m)))
-                           (sender)))))
+    (fn sender []
+      (take! out
+             (fn [m]
+               (when m
+                 (debug "sending: " m)
+                 (let [writer (transit/writer :json)]
+                   (.send channel (js/Blob. #js [(transit/write writer m)])))
+                 (sender)))))
     opener))
-
-
-(comment
-  (client-connect! "ws://127.0.0.1:9090"))
-
-
-;; fire up repl
-#_(do
-    (ns dev)
-    (def repl-env (reset! cemerick.austin.repls/browser-repl-env
-                         (cemerick.austin/repl-env)))
-    (cemerick.austin.repls/cljs-repl repl-env))

  (js/Date.))


;; TODO binary blobs
(defn client-connect!
  "Connects to url. Puts [in out] channels on return channel when ready.
Only supports websocket at the moment, but is supposed to dispatch on
protocol of url. read-opts is ignored on cljs for now, use the
platform-wide reader setup."
  [url tag-table]
  (let [host (.getDomain (goog.Uri. url))
        channel (goog.net.WebSocket. false)
        in (chan)

(ns replikativ.platform
  (:require [replikativ.platform-log :refer [debug info warn error]]
            [konserve.platform :refer [read-string-safe]]
            [cognitect.transit :as transit]
            [goog.net.WebSocket]
            [goog.events :as events]
            [cljs.core.async :as async :refer (take! put! close! chan)])
