net.liftweb.http

ListenerManager

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 { 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 => { updateListeneres(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
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ListenerManager
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. 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.

    Attributes
    protected abstract

Concrete Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  9. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  12. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  13. 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
  14. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  15. def listenerService : PartialFunction[Any, Unit]

    Attributes
    protected
  16. def lowPriority : PartialFunction[Any, Unit]

    Override this method to process low priority messages.

    Override this method to process low priority messages.

    Attributes
    protected
  17. 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

  18. def messageHandler : PartialFunction[Any, Unit]

    Attributes
    protected
  19. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  20. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  21. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  22. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  23. def toString (): String

    Definition Classes
    AnyRef → Any
  24. def updateListeners (msg: Any): Unit

    Update the listeners with a message that we create.

    Update the listeners with a message that we create. Note that with this invocation the createUpdate method is not used.

    Attributes
    protected
  25. def updateListeners (): Unit

    Update the listeners with the message generated by createUpdate

    Update the listeners with the message generated by createUpdate

    Attributes
    protected
  26. def wait (): Unit

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  28. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  29. def updateIfPassesTest (update: Any)(info: ()): Unit

    This method provides legacy functionality for filtering messages before sending to each registered actor.

    This method provides legacy functionality for filtering messages before sending to each registered actor. It is deprecated in favor of doing the filtering in the registered Actor's message handling partial functions instead.

    Attributes
    protected
    Annotations
    @deprecated
    Deprecated

    Accept/reject logic should be done in the partial function that handles the message.

Inherited from AnyRef

Inherited from Any