On Tue, Mar 2, 2010 at 6:09 AM, ced <[email protected]> wrote:
> I have a similar use case and from my experience using a CometActor is
> just great for this.
>
> > 1) I assume each page get their own instance of the actor so they can
> > hold their own data. Is this correct?
>
> Yes.
>
No, it's not correct. There's one CometActor of a given type/name per
session.
>
> > 2) When is a CometActor shutdown? Sometime after the user navigates
> > away from page?
>
> CometActors have a time to live. Override
> override def lifespan: Box[TimeSpan] = Full(2 minutes)
> in your implementation and when the actor doesn't get queried for that
> amount of time it receives a shutdown.
>
> > 3) How do I get access to the CometActor instance on the page? I need
> > to send a message to it from a function bound to e.g. an ajaxSelect
>
> You need another Actor that dispatches messages to your CometActors.
>
This is not correct. If you create an ajax component from within the scope
of the CometActor (in the CometActor's render method), any of the
CometActor's methods can be called and you can also manipulate private data
during the Ajax call. Why? Because Lift ensures that if the function was
created within the scope of the CometActor that it will always be evaluated
via a message passed to the CometActor.
> Say you have ChartCometActor, then implement something like
> object ChartManager extends Actor {
> ...
> }
> where all your CharCometActors register at creation time. Override
> localSetup() for this. Also override localShutdown() to unregister.
> Your snippet function then sends a message to the ChartManager who's
> responsible for dispatching to all/one actor/s. I use a solution where
> I register the CometActors an a session basis, so I can send a message
> either to all or just one CometActor.
>
> I have some code available that eases the registration/deregistration
> and the sending of messages on a per-session basis.
>
> Hope that helps,
> -Chris
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.