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 => { updateListeners(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. 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.

    Attributes
    protected

Concrete Value Members

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

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

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

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

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

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

    Definition Classes
    Any
  7. def clone(): AnyRef

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

    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. final def getClass(): java.lang.Class[_]

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

    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. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  22. 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
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. def toString(): String

    Definition Classes
    AnyRef → Any
  25. 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
  26. def updateListeners(): Unit

    Update the listeners with the message generated by createUpdate

    Update the listeners with the message generated by createUpdate

    Attributes
    protected
  27. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def updateIfPassesTest(update: Any)(info: (SimpleActor[Any], PartialFunction[Any, Boolean])): 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

    (Since version 2.4) Accept/reject logic should be done in the partial function that handles the message.

Inherited from AnyRef

Inherited from Any