On Sun, Nov 8, 2009 at 11:28 PM, Jack Widman <[email protected]> wrote:

> Thanks David. This is a big help. Can you tell me exactly how lowPriority,
> mediumPriorty and highPriority work? When are they called?
>

When a message comes into the Actor's mailbox, the Actor determines if it
can handle the message.  CometActors have a set of messages they can (must)
handle related to being a CometActor, but each CometActor is going to be
customized, so it must be able to handle extra messages.  The CometActor
builds a PartialFunction to determine if it can handle messages by:

val handler = highPriority orElse builtIn orElse mediumPriority orElse
lowPriority

The handler (built each time a message is tested or dispatched, so you can
dynamically change the message handling) is tested against the message
(isDefinedAt) and if it can handle the message, the message is removed from
the mailbox and dispatched (apply).  If the message cannot be dispatched,
the next message in the mailbox is tested and so on until there are no more
messages that can be dispatched.


>
> On Sun, Nov 8, 2009 at 11:35 PM, David Pollak <
> [email protected]> wrote:
>
>> Jack,
>>
>> I reproduced your code and it seems to work fine.  I've enclosed a working
>> copy.
>>
>> Some comments about your code:
>>
>>    - The foos variable and the foo variable may be getting confused in
>>    the code... the render method may be rendering the same thing based on the
>>    unchanging foos variable.
>>    - Doing null testing is a sign that you have logic errors in your
>>    code.  I strongly recommend using either Box or Option for everything that
>>    can logically not contain a value/reference.  If you're bridging out to 
>> Java
>>    code and are expecting null from the Java code, write a small bridge that
>>    will wrapper the Java return values in Box/Option.
>>    - You have a case class (Tick) that contains no parameters.  Please
>>    use a case object instead.
>>    - Your Tick look is a spin loop.  You fire a Tick message as part of
>>    processing the Tick message.  I would suggest that if you're polling, that
>>    you have a reasonable poll interval, otherwise you'll starve your CPU.
>>    Further, having reRender on each loop through means that you're forcing a
>>    lot of bytes over the wire rather than only doing a reRender on changed
>>    values.
>>
>> Thanks,
>>
>> David
>>
>> On Sun, Nov 8, 2009 at 3:47 PM, Jack Widman <[email protected]>wrote:
>>
>>> Sorry. Here it is:   As I said, I know that when render is called,
>>> foo.getValue has the right value. But it does not show on the screen, unless
>>> I refresh the browser.
>>>
>>> package com.foo.comet
>>>
>>> import net.liftweb._
>>> import http._
>>> import js._
>>> import JsCmds._
>>> import net.liftweb.util._
>>> import net.liftweb.http._
>>> import _root_.scala.xml._
>>> import scala.actors._
>>> import com.authoritude.snippet._
>>> import scala.collection.mutable.Queue
>>> import net.liftweb.http.SessionVar
>>>
>>>
>>> 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 = {
>>>     super.localSetup
>>>     this ! Tick
>>>   }
>>>
>>>   var foo:Foo = null
>>>   override def lowPriority = {
>>>     case Tick => {
>>>       foo=FooQueue.getLatest
>>>       if (foo!=null && foo.getValue > -1) {
>>>     blogs = FooManager.process(foo, foos)
>>>       } else if (foo!=null){
>>>     foos = foos.remove((f:Foo)=>(f.id==foo.id))
>>>       }
>>>       reRender(false)
>>>       this ! Tick
>>>     }
>>>   }
>>> }
>>>
>>> case class Tick
>>>
>>>
>>>
>>> On Sun, Nov 8, 2009 at 5:31 AM, Timothy Perrett <[email protected]
>>> > wrote:
>>>
>>>>
>>>> Without posting your code it's going to be tough to help you.
>>>>
>>>> Cheers, Tim
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On 8 Nov 2009, at 08:14, jack <[email protected]> wrote:
>>>>
>>>> >
>>>> > By the way, I know that when render is called, all the variables have
>>>> > the right values. I just don't see it on the screen unless I refresh
>>>> > it.
>>>> >
>>>> > On Nov 8, 3:12 am, jack <[email protected]> wrote:
>>>> >> I have a CometActor. render is called when it is supposed to be but I
>>>> >> don't see the changes. If I refresh the page at anytime, I do see the
>>>> >> changes. Any idea what might cause this?
>>>> > >
>>>> >
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Jack Widman
>>>
>>> co-founder / cto,  Authoritude, Inc.
>>>
>>> 203-641-9355
>>>
>>>
>>>
>>>
>>
>>
>> --
>> 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
>>
>>
>>
>>
>
>
> --
> Jack Widman
>
> co-founder / cto,  Authoritude, Inc.
>
> 203-641-9355
>
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to