change some default connection/timeout settings

This commit is contained in:
Gered 2014-12-27 17:41:28 -05:00
parent 143939af61
commit 17f15b797b
2 changed files with 20 additions and 13 deletions

View file

@ -78,22 +78,27 @@
You can specify the same set of options that
net.thegeez.browserchannel/wrap-browserchannel accepts, except for
:on-session (which will be overridden even if you do try to pass it).
See net.thegeez.browserchannel/default-options for more info.
Note that if :base is not specified, the default is '/browserchannel'
(this differs from net.thegeez.browserchannel/wrap-browserchannel).
See net.thegeez.browserchannel/default-options for more info on available
options and what the defaults are. Some defaults are different when
using this middleware:
In addition, you can pass event handler functions. Note that the return
value for all of these handlers is not used."
:base \"/browserchannel\"
:keep-alive-interval 20
:session-timeout-interval 30"
[handler & [opts]]
(-> handler
(browserchannel/wrap-browserchannel
(assoc
opts
:base (or (:base opts) "/browserchannel")
:on-session
(fn [browserchannel-session-id request]
(handle-session browserchannel-session-id request))))))
(let [opts (merge
{:base "/browserchannel"
:keep-alive-interval 20
:session-timeout-interval 30}
opts)]
(-> handler
(browserchannel/wrap-browserchannel
(assoc
opts
:on-session
(fn [browserchannel-session-id request]
(handle-session browserchannel-session-id request)))))))
(defn init!
"Sets up browserchannel for server-side use. This function should be called

View file

@ -176,6 +176,8 @@
(.disconnect browser-channel)
(events/removeAll)))
(set-debug-logger! goog.debug.Logger.Level.OFF)
; this seems to help prevent premature session timeouts from occuring (vs the default of 3)
(set! goog.net.BrowserChannel/BACK_CHANNEL_MAX_RETRIES 20)
(.setHandler browser-channel (->handler))
(.connect browser-channel
(str base "/test")