Skip to content

Commit

Permalink
Replace S.addCometAtEnd with S.addComet.
Browse files Browse the repository at this point in the history
S.addComet takes a LiftCometActor instead of an Elem. It
replaces the private trackComet that simply added an entry
to S.requestCometVersions.

Additionally, this makes server-side actors and roundtrip
streaming promises work again.
  • Loading branch information
Shadowfiend committed May 10, 2014
1 parent 316af3e commit 38f480c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
6 changes: 0 additions & 6 deletions web/webkit/src/main/scala/net/liftweb/http/LiftMerge.scala
Expand Up @@ -196,12 +196,6 @@ private[http] trait LiftMerge {
headChildren += nl
}

for {
e <- S.cometAtEnd()
} {
_fixHtml(e, true, false, false, true, false, false, true, false)
}

// Appends ajax script to body
if (LiftRules.autoIncludeAjaxCalc.vend().apply(this)) {
bodyChildren +=
Expand Down
8 changes: 2 additions & 6 deletions web/webkit/src/main/scala/net/liftweb/http/LiftSession.scala
Expand Up @@ -2356,9 +2356,7 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,

ca ! PerformSetupComet2(Empty)

val node: Elem = ca.buildSpan(NodeSeq.Empty)

S.addCometAtEnd(node)
S.addComet(ca)

ca ! SetDeltaPruner(lastWhenDeltaPruner)

Expand Down Expand Up @@ -2828,9 +2826,7 @@ class LiftSession(private[http] val _contextPath: String, val uniqueId: String,

ca ! SetDeltaPruner(lastWhenDeltaPruner)

val node: Elem = ca.buildSpan(NodeSeq.Empty)

S.addCometAtEnd(node)
S.addComet(ca)

val currentReq: Box[Req] = S.request.map(_.snapshot)

Expand Down
26 changes: 13 additions & 13 deletions web/webkit/src/main/scala/net/liftweb/http/S.scala
Expand Up @@ -362,7 +362,11 @@ trait S extends HasParams with Loggable with UserAgentCalculator {
*/
private object _tailTags extends TransientRequestVar(new ListBuffer[Elem])

private object _cometTags extends TransientRequestVar(new ListBuffer[Elem])
// Set of CometVersionPairs for comets that should be tracked on
// the page that is currently being rendered or that called this AJAX
// callback.
private[http] object requestCometVersions extends TransientRequestVar[Set[CometVersionPair]](Set.empty)


private object p_queryLog extends TransientRequestVar(new ListBuffer[(String, Long)])
private object p_notice extends TransientRequestVar(new ListBuffer[(NoticeType.Value, NodeSeq, Box[String])])
Expand Down Expand Up @@ -797,14 +801,12 @@ trait S extends HasParams with Loggable with UserAgentCalculator {
*/
def atEndOfBody(): List[Elem] = _tailTags.is.toList

def addCometAtEnd(elem: Elem): Unit = _cometTags.is += elem

// Set of CometVersionPairs for comets that should be tracked on
// the page that is currently being rendered or that called this AJAX
// callback.
private[http] object requestCometVersions extends TransientRequestVar[Set[CometVersionPair]](Set.empty)

private def trackComet(cometActor: LiftCometActor) = {
/**
* Add a comet to the list of comets that should be registered to
* receive updates on the page currently being rendered or on the page
* that invoked the currently running callback.
*/
def addComet(cometActor: LiftCometActor): Unit = {
requestCometVersions.set(
requestCometVersions.is + CVP(cometActor.uniqueId, cometActor.lastListenerTime)
)
Expand Down Expand Up @@ -832,7 +834,7 @@ trait S extends HasParams with Loggable with UserAgentCalculator {
cometActor <- session.findOrCreateComet(cometType, cometName, cometHtml, cometAttributes)
} yield {
if (receiveUpdatesOnPage)
trackComet(cometActor)
addComet(cometActor)

cometActor
}
Expand All @@ -859,14 +861,12 @@ trait S extends HasParams with Loggable with UserAgentCalculator {
cometActor <- session.findOrCreateComet[T](cometName, cometHtml, cometAttributes)
} yield {
if (receiveUpdatesOnPage)
trackComet(cometActor)
addComet(cometActor)

cometActor
}
}

def cometAtEnd(): List[Elem] = _cometTags.is.toList

/**
* Sometimes it's helpful to accumute JavaScript as part of servicing
* a request. For example, you may want to accumulate the JavaScript
Expand Down

0 comments on commit 38f480c

Please sign in to comment.