Packages

trait ListenerManager extends AnyRef

This trait manages a set of Actors in a publish/subscribe pattern. When you extend your Actor with this trait, you automatically get handling for sending messages out to all subscribed Actors. Simply override the high-, medium-, or lowPriority handlers to do your message processing. When you want to update all subscribers, just call the updateListeners method. The createUpdate method is used to generate the message that you want sent to all subscribers.

Note that the AddAListener and RemoveAListener messages (for subscription control) are processed after any highPriority or mediumPriority messages are processed, so take care to avoid overly broad matches in those handlers that might consume internal messages.

For example, you could write a simple service to provide clock ticks using the following code:

case object Tick

object Ticker extends ListenerManager with LiftActor {
  import net.liftweb.util.ActorPing

  // Set up the initial tick
  ActorPing.schedule(this, Tick, 1000L)

  // This is a placeholder, since we're only interested
  // in Ticks
  def createUpdate = "Registered"

  override def mediumPriority = {
    case Tick => {
      sendListenersMessage(Tick)
      ActorPing.schedule(this, Tick, 1000L)
}
}
}

A client CometActor could look like:

class CometClock extends CometListener {
  val registerWith = Ticker

  ... handling code ...
}

Self Type
ListenerManager with SimpleActor[Any]
See also

CometListener

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ListenerManager
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def createUpdate: Any

    This method is called when the

    updateListeners()
    
    method needs a message to send to subscribed Actors.

    This method is called when the

    updateListeners()
    
    method needs a message to send to subscribed Actors. In particular, createUpdate is used to create the first message that a newly subscribed CometListener will receive.

    updateListeners() needs a message to send to subscribed Actors. In particular, createUpdate is used to create the first message that a newly subscribed CometListener will receive.

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  11. def highPriority: PartialFunction[Any, Unit]

    Override this method to process high priority messages.

    Override this method to process high priority messages. Note: you must not process messages with a wildcard (match all), since this will intercept the messages used for subscription control.

    Attributes
    protected
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. def listenerService: PartialFunction[Any, Unit]
    Attributes
    protected
  14. def lowPriority: PartialFunction[Any, Unit]

    Override this method to process low priority messages.

    Override this method to process low priority messages.

    Attributes
    protected
  15. def mediumPriority: PartialFunction[Any, Unit]

    Override this method to process medium priority messages.

    Override this method to process medium priority messages. See the highPriority method for an important note on wildcard processing.

    Attributes
    protected
    See also

    #highPriority

  16. def messageHandler: PartialFunction[Any, Unit]
    Attributes
    protected
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  20. def onListenersListEmptied(): Unit

    Called after RemoveAListener-message is processed and no more listeners exist.

    Called after RemoveAListener-message is processed and no more listeners exist. Default does nothing.

    Attributes
    protected
  21. def sendListenersMessage(msg: Any): Unit

    Send a message we create to all of the listeners.

    Send a message we create to all of the listeners. Note that with this invocation the createUpdate method is not used.

    Attributes
    protected
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. def updateListeners(listeners: List[ActorTest] = listeners): Unit

    Update the listeners with the message generated by createUpdate

    Update the listeners with the message generated by createUpdate

    Attributes
    protected
  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped