On Mon, Dec 7, 2009 at 5:45 AM, Neil.Lv <anim...@gmail.com> wrote:

>
>   I think maybe it's a bug ~?
>
>   Btw, Does anybody know how to convert the CometActor to LiftActor.
>

A CometActor is a subclass of LiftActor

If you can package up a complete simple implementation of the problem (an
app I can run with mvn jetty:run), I'll take a look at it.


>
>   And how the write the render method and use the "ActorPing.schedule
> (this, Tick, 10 seconds)"
> in LiftActor.
>




>
>   Thanks for any suggestion!
>
> Cheers,
>  Neil
> ###
> package com.liftcode.comet
>
> import net.liftweb._
> import http._
> import js._
> import JsCmds._
> import net.liftweb.common._
> import net.liftweb.util._
> import Helpers._
> import net.liftweb.http._
> import _root_.scala.xml._
> import scala.actors._
> import scala.collection.mutable.Queue
> import net.liftweb.http.SessionVar
>
> case class Foo(getValue: String)
>
> object FooManager {
>  private var foos: List[Foo] = Nil
>  def getFoos: List[Foo] = synchronized {
> println("........  foos size: " + foos.size)
>    foos ::= Foo(System.currentTimeMillis.toString)
>    foos
>  }
>
> }
>
> class MyComet extends CometActor {
>
>  override def defaultPrefix = Full("auth")
>
>  private var foos = FooManager.getFoos
>
>  def createDisplay(foos:List[Foo]):NodeSeq = {
>    <span id="go"><table>
>    {
>      for {foo <- foos} yield <tr><td>{foo.getValue}</td></tr>
>    }
>
>    </table></span>
>  }
>
>  def render = { bind("foo" -> createDisplay(foos)) }
>
>  override def localSetup = {
> println("........  localSetup: " )
>    super.localSetup
>    this ! Tick
>  }
>
>  override def lowPriority = {
>    case Tick => {
> println("....   Tick ....")
>      foos = FooManager.getFoos
>      reRender(false)
>      ActorPing.schedule(this, Tick, 10 seconds)
>    }
>  }
>
> }
>
> case object Tick
> ###
>
> On Dec 7, 9:40 pm, "Neil.Lv" <anim...@gmail.com> wrote:
> >   Here is the server log,
> >
> > ###
> > INFO - Service request (GET) /comet_request/27036331510/b0iubsv7usc1
> > took 0 Mill
> > iseconds
> > INFO - Service request (GET) /comet_request/24195135706/1geup5f5uelih
> > took 0 Mil
> > liseconds
> > INFO - Service request (GET) /comet_request/15421125743/b0iubsv7usc1
> > took 0 Mill
> > iseconds
> > INFO - Service request (GET) /comet_request/4886038816/b0iubsv7usc1
> > took 15 Mill
> > iseconds
> > INFO - Service request (GET) /comet_request/70554035677/b0iubsv7usc1
> > took 0 Mill
> > iseconds
> > INFO - Service request (GET) /comet_request/80058340958/b0iubsv7usc1
> > took 0 Mill
> > iseconds
> > INFO - Service request (GET) /comet_request/16073680948/b0iubsv7usc1
> > took 0 Mill
> > iseconds
> > INFO - Service request (GET) /comet_request/48475840285/b0iubsv7usc1
> > took 16 Mil
> > liseconds
> > ###
> >
> >    I set the time is 10 seconds, but here is wrong.
> >
> >    Does anybody know about the issue ?
> >
> > Cheers,
> >   Neil
> >
> > On Dec 4, 3:00 pm, "Neil.Lv" <anim...@gmail.com> wrote:
> >
> > > Hi all,
> >
> > >    Here is an example code that about the ActorComet.
> >
> > > ###
> > > package com.liftcode.comet
> >
> > > import net.liftweb._
> > > import http._
> > > import js._
> > > import JsCmds._
> > > import net.liftweb.common._
> > > import net.liftweb.util._
> > > import Helpers._
> > > import net.liftweb.http._
> > > import _root_.scala.xml._
> > > import scala.actors._
> > > import scala.collection.mutable.Queue
> > > import net.liftweb.http.SessionVar
> >
> > > case class Foo(getValue: String)
> >
> > > object FooManager {
> > >   private var foos: List[Foo] = Nil
> > >   def getFoos: List[Foo] = synchronized {
> > > println("........  foos size: " + foos.size)
> > >     foos ::= Foo(System.currentTimeMillis.toString)
> > >     foos
> > >   }
> >
> > > }
> >
> > > class MyComet extends CometActor {
> >
> > >   override def defaultPrefix = Full("auth")
> >
> > >   private var foos = FooManager.getFoos
> >
> > >   def createDisplay(foos:List[Foo]):NodeSeq = {
> > >     <span id="go"><table>
> > >     {
> > >       for {foo <- foos} yield <tr><td>{foo.getValue}</td></tr>
> > >     }
> >
> > >     </table></span>
> > >   }
> >
> > >   def render = { bind("foo" -> createDisplay(foos)) }
> >
> > >   override def localSetup = {
> > > println("........  localSetup: " )
> > >     super.localSetup
> > >     this ! Tick
> > >   }
> >
> > >   override def lowPriority = {
> > >     case Tick => {
> > > println("....   Tick ....")
> > >       foos = FooManager.getFoos
> > >       reRender(false)
> > >       ActorPing.schedule(this, Tick, 10 seconds)
> > >     }
> > >   }
> >
> > > }
> >
> > > case object Tick
> > > ###
> >
> > >    When i run  mvn jetty:run  to start the server, and type
> thehttp://localhost:8080inthe browser.
> > > The result will be like this, the println("....   Tick ....") method
> > > only execute 1 time every 10 seconds.
> >
> > > ###
> > > INFO - Service request (GET) /comet_request/50054201120/farmqqw03xkm
> > > took 46 Mil
> > > liseconds
> > > ....   Tick ....
> > > ........  foos size: 2
> > > INFO - Service request (GET) /comet_request/87077494133/farmqqw03xkm
> > > took 8625 M
> > > ###
> >
> > >    Then i don't close the browser, and Ctrl+C stop the jetty server,
> > > and  mvn jetty:run  restart the server, the result will be like this:
> > > The  println("....   Tick ....") method will be execute 3 times every
> > > 10 seconds.
> >
> > > ###
> > > INFO - Service request (GET) /comet_request/74875169086/farmqqw03xkm
> > > took 0 Mill
> > > iseconds
> > > ........  foos size: 8
> > > ........  localSetup:
> > > ....   Tick ....
> > > ........  foos size: 9
> > > INFO - Service request (GET) / took 109 Milliseconds
> > > ........  foos size: 10
> > > ........  localSetup:
> > > ....   Tick ....
> > > ........  foos size: 11
> > > INFO - Service request (GET) / took 31 Milliseconds
> > > ###
> >
> > >    I don't know what's wrong with it .
> > >    If when you stop the server, and close the browser immediately,
> > > then use mvn jetty:run to start the server, and open a new browser to
> > > visithttp://localhost:8080,  the result is correctly.
> >
> > >    Thanks for any suggestion!
> >
> > > Cheers,
> > >   Neil
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to