Improve memory efficiency by writing more frequently to back-channel.
This commit is contained in:
parent
68440ee178
commit
68d2ebc633
|
@ -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"]]}})
|
||||
|
|
|
@ -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"]]
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue