CaptureListener-class: Class '"CaptureListener"'

CaptureListener-classR Documentation

Class "CaptureListener"

Description

This listener simply takes its messages and adds them to a list. It is is mainly used for testing the message system.

Details

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.

Extends

This class implements the Listener interface.

All reference classes extend and inherit methods from "envRefClass".

Methods

isListener

signature(x = "CaptureListener"): returns true.

receiveMessage

signature(x = "CaptureListener"): If the message is in the messSet, it adds the message to the message list. (See details)

listenerName

signature(x= "InjectionListener"): Returns the name assigned to the listener.

listenerDataTable

signature(listener = "CaptureListener", appid ): Builds a data datable from the messages.

Data Table

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.

Fields

messages:

Object of class list the list of messages in reverse chronological order.

Class-Based Methods

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.

Author(s)

Russell Almond

References

This is an example of the observer design pattern. https://en.wikipedia.org/wiki/Observer_pattern.

See Also

Listener, P4Message, CaptureListener, UpdateListener, UpsertListener, InjectionListener, TableListener,

Examples


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()))


ralmond/Proc4 documentation built on June 13, 2025, 7:13 a.m.