diff --git a/clj-browserchannel-jetty-adapter/project.clj b/clj-browserchannel-jetty-adapter/project.clj index 3d774ce..4849f4d 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.3" +(defproject net.thegeez/clj-browserchannel-jetty-adapter "0.0.4" :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.0.7"]] + [net.thegeez/clj-browserchannel-server "0.0.8"]] :profiles {:provided {:dependencies [[org.clojure/clojure "1.6.0"]]}}) diff --git a/clj-browserchannel-server/project.clj b/clj-browserchannel-server/project.clj index e8ce226..31414dd 100644 --- a/clj-browserchannel-server/project.clj +++ b/clj-browserchannel-server/project.clj @@ -1,4 +1,4 @@ -(defproject net.thegeez/clj-browserchannel-server "0.0.7" +(defproject net.thegeez/clj-browserchannel-server "0.0.8" :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 1180e7f..80e8923 100644 --- a/clj-browserchannel-server/src/net/thegeez/browserchannel.clj +++ b/clj-browserchannel-server/src/net/thegeez/browserchannel.clj @@ -128,6 +128,14 @@ (defn error-response [status-code message] {:status status-code :body (str "

" message "

")}) + +(defn agent-error-handler-fn + "Prints the error and tries to restart the agent." + [id] + (fn [ag ^Exception e] + (println "ERROR:" id "agent threw" e (.getMessage e)) + (restart-agent ag @ag))) + ;;;;;; end of utils ;;;; listeners @@ -136,6 +144,8 @@ ;; sessionId -> :event -> [call back] ;; event: :map | :close (def listeners-agent (agent {})) +(set-error-handler! listeners-agent (agent-error-handler-fn "listener")) + (defn add-listener [session-id event-key f] (send-off listeners-agent @@ -506,6 +516,7 @@ ;; when the client never connects with a backchannel refresh-session-timeout) session-agent (agent session)] + (set-error-handler! session-agent (agent-error-handler-fn (str "session-" (:id session)))) (swap! sessions assoc id session-agent) (when-let [notify (:on-session options)] (notify id req))