allow data to be sent included in the new session forward ch request
this is part of the browserchannel protocol and can be an optimization for some applications (less round trips to the server when the app is establishing the browserchannel session)
This commit is contained in:
parent
2ced218750
commit
47f6a6d946
|
@ -707,6 +707,14 @@
|
||||||
[(create-session-agent req options) true])
|
[(create-session-agent req options) true])
|
||||||
;; maps contains whatever the messages to the server
|
;; maps contains whatever the messages to the server
|
||||||
maps (get-maps req)]
|
maps (get-maps req)]
|
||||||
|
;; if maps were received in this request, we should forward to listeners
|
||||||
|
;; (client is allowed to send requests in the new session request as well,
|
||||||
|
;; so for both existing sessions and new sessions we do this)
|
||||||
|
(if (and (seq maps)
|
||||||
|
session-agent)
|
||||||
|
(doseq [m maps]
|
||||||
|
(let [decoded (decode-map m)]
|
||||||
|
(notify-listeners (:id @session-agent) req :map decoded))))
|
||||||
(if is-new-session
|
(if is-new-session
|
||||||
;; first post after a new session is a message with the session
|
;; first post after a new session is a message with the session
|
||||||
;; details.
|
;; details.
|
||||||
|
@ -721,19 +729,14 @@
|
||||||
:headers (assoc (:headers options) "Content-Type" "application/javascript")
|
:headers (assoc (:headers options) "Content-Type" "application/javascript")
|
||||||
:body (size-json-str (json/generate-string [[0, ["c", session-id, host-prefix, protocol-version]]]))})
|
:body (size-json-str (json/generate-string [[0, ["c", session-id, host-prefix, protocol-version]]]))})
|
||||||
;; For existing sessions:
|
;; For existing sessions:
|
||||||
;; Forward sent data by client to listeners
|
|
||||||
;; reply with
|
;; reply with
|
||||||
;; [backchannelPresent,lastPostResponseArrayId_,numOutstandingBackchannelBytes]
|
;; [backchannelPresent,lastPostResponseArrayId_,numOutstandingBackchannelBytes]
|
||||||
;; backchannelPresent = 0 for false, 1 for true
|
;; backchannelPresent = 0 for false, 1 for true
|
||||||
;; send as json for XHR and IE
|
;; send as json for XHR and IE
|
||||||
(do
|
(let [status (session-status @session-agent)]
|
||||||
(doseq [m maps]
|
{:status 200
|
||||||
(let [decoded (decode-map m)]
|
:headers (:headers options)
|
||||||
(notify-listeners (:id @session-agent) req :map decoded)))
|
:body (size-json-str (json/generate-string status))}))))
|
||||||
(let [status (session-status @session-agent)]
|
|
||||||
{:status 200
|
|
||||||
:headers (:headers options)
|
|
||||||
:body (size-json-str (json/generate-string status))})))))
|
|
||||||
|
|
||||||
;; GET req server->client is a backwardchannel opened by client
|
;; GET req server->client is a backwardchannel opened by client
|
||||||
(defn- handle-backward-channel
|
(defn- handle-backward-channel
|
||||||
|
|
Reference in a new issue