ensure initial session timeout can actually timeout on new session

the way this was being triggered would cause the session timeout to
be triggered at the proper timeout interval, but due to the call
to refresh-session-timeout not being done via the session agent and
the use of send-off, the session timeout handler would not have any
way to actually remove the session from the global sessions atom

in practice this would only actually be a problem if clients were
creating a session and then never performing a GET request to create
a backchannel
This commit is contained in:
Gered 2016-05-12 13:08:50 -04:00
parent e597737204
commit 1b3a0e99bc

View file

@ -532,28 +532,30 @@
:heartbeat-interval (:keep-alive-interval options)
:session-timeout-interval (:session-timeout-interval options)
:data-threshold (:data-threshold options)}
session (-> (Session. id
details
nil ;; backchannel
(ArrayBuffer.
0 ;; array-id, 0 is never used by the
;; array-buffer, it is used by the
;; first message with the session id
0 ;; last-acknowledged-id
;; to-acknowledge-arrays
clojure.lang.PersistentQueue/EMPTY
;; to-flush-arrays
clojure.lang.PersistentQueue/EMPTY)
nil ;; heartbeat-timeout
nil ;; session-timeout
)
;; this first session-timeout is for the case
;; when the client never connects with a backchannel
refresh-session-timeout)
session (Session. id
details
nil ;; backchannel
(ArrayBuffer.
0 ;; array-id, 0 is never used by the
;; array-buffer, it is used by the
;; first message with the session id
0 ;; last-acknowledged-id
;; to-acknowledge-arrays
clojure.lang.PersistentQueue/EMPTY
;; to-flush-arrays
clojure.lang.PersistentQueue/EMPTY)
nil ;; heartbeat-timeout
nil ;; session-timeout
)
session-agent (agent session)]
(set-error-handler! session-agent (agent-error-handler-fn (str "session-" (:id session))))
(set-error-mode! session-agent :continue)
;; add new session-agent to our list of active browserchannel sessions
(swap! sessions assoc id session-agent)
;; this first session-timeout is for the case
;; when the client never connects with a backchannel
(send-off session-agent refresh-session-timeout)
;; register application-level browserchannel session events
(let [{:keys [on-open on-close on-receive]} (:events options)]
(if on-close (add-listener id :close on-close))
(if on-receive (add-listener id :map on-receive))