Ok, good to know.

For people looking to extend David's code earlier in this thread to
have Comet listeners receive some, and not all, object creation
events, take a look at David's Skittr code[1], namely UserActor[2],
UserList[3], and WatchUser[4]. Basically, a singleton object (UserList
in Skittr's case) stores a HashMap of string keys and actors (e.g.
UserActor) and the Comet listeners (e.g. WatchUser) ask it for the
appropriate actors and register themselves with them. If people want
to know more, I'm willing to do a writeup.

Peter

[1]: 
http://blog.lostlake.org/index.php?/archives/55-Prance-with-the-Horses,-Skittr-with-the-Mice.html
[2]:
http://github.com/dpp/liftweb/blob/617f752f3824005768e255089f847720b5e67f2a/sites/skittr/src/main/scala/com/skittr/actor/UserActor.scala
[3]:
http://github.com/dpp/liftweb/blob/617f752f3824005768e255089f847720b5e67f2a/sites/skittr/src/main/scala/com/skittr/actor/UserList.scala
[4]:
http://github.com/dpp/liftweb/blob/617f752f3824005768e255089f847720b5e67f2a/sites/skittr/src/main/scala/com/skittr/comet/WatchUser.scala


On Jul 22, 9:30 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Tue, Jul 21, 2009 at 2:04 PM, Peter Robinett 
> <pe...@bubblefoundry.com>wrote:
>
>
>
> > Hi David,
>
> > I'm looking to use your code in my application but first I wanted to
> > ask you about Scala Actors versus LiftActors. I see you use the Scala
> > ones here. Why is that? Would it be better to use your Lift ones? I'm
> > expecting object creation in my app every few seconds and when
> > responding it would like to update Flot charts and various other
> > components using Comet.
>
> The issue with Scala Actors is the number of Actor creation/destruction
> operations.  You'll create an Actor per session... not a lot of cycling.
>
> I'd go with Scala Actors.
>
>
>
>
>
> > Thanks for your advice,
> > Peter Robinett
>
> > On Jul 9, 2:36 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> > > On Mon, Jul 6, 2009 at 7:56 AM, Tobias Daub <hannes.flo...@gmx.li>
> > wrote:
>
> > > > Hi List,
>
> > > > I wanna send a message to an Actor everytime a new "row" is created in
> > a
> > > > specific table. The Actor is responsible to refresh a HTML page and
> > > > display all the items from the table.
>
> > > > How do I do that?
>
> > > In the Meta object for the model you want to track, override afterCreate
> > to
> > > call a method that sends the row to an Actor:
>
> > > object Dog extends Dog with LongKeyedMetaMapper[Dog] with CRUDify[Long,
> > Dog]
> > > {
> > >   override def afterCreate = createdRow _ :: super.afterCreate
>
> > >   private def createdRow(r: Dog) {
> > >     DogBroker ! r
> > >   }
>
> > > }
>
> > > The actor redistributes the update to all its listeners:
>
> > > object DogBroker extends Actor with ListenerManager {
> > >   var latestDog: Box[Dog] = Empty
>
> > >   def createUpdate = latestDog
>
> > >   override def highPriority = {
> > >     case d: Dog =>
> > >       latestDog = Full(d)
> > >       updateListeners()
> > >   }
>
> > >   this.start
>
> > > }
>
> > > And the comet component looks like:
>
> > > class Woof extends CometActor with CometListener {
> > >   private var dog: Box[Dog] = Empty
>
> > >   def render = <div>Dog: {dog.map(_.toString) openOr "None"}</div>
>
> > >   def registerWith = DogBroker
>
> > >   override def highPriority = {
> > >     case Full(d: Dog) =>
> > >       dog = Full(d)
> > >       reRender(false)
> > >   }
>
> > > }
>
> > > The full running source can be found athttp://
> > github.com/dpp/lift_1_1_sample/tree/record_ping
>
> > > Thanks,
>
> > > David
>
> > > > thanks.
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Git some:http://github.com/dpp
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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