CaptureListener-class | R Documentation |
"CaptureListener"
This listener simply takes its messages and adds them to a list. It is is mainly used for testing the message system.
This listener simply takes all messages and pushes them onto the
messages
field. The messages
field is the complete
list of received messages, most recent to most ancient. The method
lastMessage()
returns the most recent message.
This class implements the Listener
interface.
All reference classes extend and inherit methods from
"envRefClass"
.
signature(x = "CaptureListener")
: returns
true.
signature(x = "CaptureListener")
: If
the message is in the messSet
, it adds the message to the
message list. (See details)
signature(x= "InjectionListener")
: Returns the name assigned to the listener.
signature(listener =
"CaptureListener", appid )
: Builds a data datable from the messages.
When the listenerDataTable
method is called, the table
is made by applying the attributes
function to the
$messages
list. As these are presumably
P4Message
objects, this will expose the fields as
a database.
messages
:Object of class list
the list of
messages in reverse chronological order.
lastMessage()
:Returns the most recent message.
receiveMessage(mess)
:Does the work of inserting the message. See Details.
reset(app)
:Empties the message list.
initialize(messages, ...)
:Sets the default values for the fields.
Russell Almond
This is an example of the observer design pattern. https://en.wikipedia.org/wiki/Observer_pattern.
Listener
, P4Message
,
CaptureListener
,
UpdateListener
,
UpsertListener
,
InjectionListener
,
TableListener
,
mess1 <- P4Message(app="default",uid="Phred",context="Down Hill",
sender="EABN",mess="Statistics",
details=list("Physics_EAP"=0.5237,"Physics_Mode"="High"))
cl <- CaptureListener()
receiveMessage(cl,mess1)
stopifnot(all.equal(mess1,cl$lastMessage()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.