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
- Alphabetic
- By Inheritance
- ListenerManager
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
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
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
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
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
listenerService: PartialFunction[Any, Unit]
- Attributes
- protected
-
def
lowPriority: PartialFunction[Any, Unit]
Override this method to process low priority messages.
Override this method to process low priority messages.
- Attributes
- protected
-
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
-
def
messageHandler: PartialFunction[Any, Unit]
- Attributes
- protected
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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
-
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
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )