diff --git a/clj-browserchannel-jetty-adapter/project.clj b/clj-browserchannel-jetty-adapter/project.clj index caf8cab..361eba1 100644 --- a/clj-browserchannel-jetty-adapter/project.clj +++ b/clj-browserchannel-jetty-adapter/project.clj @@ -1,10 +1,10 @@ -(defproject net.thegeez/clj-browserchannel-jetty-adapter "0.0.7" +(defproject net.thegeez/clj-browserchannel-jetty-adapter "0.0.8" :description "Jetty async adapter for BrowserChannel" :url "" :dependencies [[ring/ring-core "1.3.1"] [ring/ring-servlet "1.3.1"] [org.eclipse.jetty/jetty-server "8.1.16.v20140903"];; includes ssl - [net.thegeez/clj-browserchannel-server "0.2.0"]] + [net.thegeez/clj-browserchannel-server "0.2.1"]] :profiles {:provided {:dependencies [[org.clojure/clojure "1.6.0"]]}}) diff --git a/clj-browserchannel-server/project.clj b/clj-browserchannel-server/project.clj index abd1d3d..b84964f 100644 --- a/clj-browserchannel-server/project.clj +++ b/clj-browserchannel-server/project.clj @@ -1,4 +1,4 @@ -(defproject net.thegeez/clj-browserchannel-server "0.2.0" +(defproject net.thegeez/clj-browserchannel-server "0.2.1" :description "BrowserChannel server implementation in Clojure" :dependencies [[ring/ring-core "1.3.1"] [org.clojure/data.json "0.2.5"]] diff --git a/clj-browserchannel-server/src/net/thegeez/browserchannel.clj b/clj-browserchannel-server/src/net/thegeez/browserchannel.clj index cd7c75a..56ef71c 100644 --- a/clj-browserchannel-server/src/net/thegeez/browserchannel.clj +++ b/clj-browserchannel-server/src/net/thegeez/browserchannel.clj @@ -328,6 +328,8 @@ ;; this is used for diagnostic purposes by the client bytes-sent]) +(defn to-pair [p] (str "[" (first p) "," (second p) "]")) + (defrecord Session [;; must be unique id @@ -436,11 +438,10 @@ (try ;; buffer contains [[1 json-str] ...] can't use ;; json-str which will double escape the json - (let [data (str "[" - (str/join "," (map (fn [[n d]] (str "[" n "," d "]")) to-flush)) - "]")] - ;; write throws exception when the connection is closed - (write (:respond back-channel) data)) + + (doseq [p to-flush #_(next to-flush)] + (write (:respond back-channel) (str "[" (to-pair p) "]"))) + ;; size is an approximation (let [this (let [size (reduce + 0 (map count (map second to-flush)))] (-> this