ListenerConstructors {Proc4} | R Documentation |
These functions create objects of class
CaptureListener
, UpdateListener
,
UpsertListener
,
InjectionListener
, and
TableListener
.
CaptureListener(messages = list(), ...) InjectionListener(sender = "sender", dbname = "test", dburi = "mongodb://localhost", messSet = character(), colname = "Messages", ...) UpdateListener(dbname = "test", dburi = "mongodb://localhost", messSet = character(), colname = "Messages", targetField = "data", qfields = c("app", "uid"), jsonEncoder = "unparseData", ...) UpsertListener(sender = "sender", dbname = "test", dburi = "mongodb://localhost", messSet = character(), colname = "Messages", qfields = c("app", "uid"), ...) TableListener(name = "ppData", fieldlist = c(uid = "character", context = "character"), messSet = character(), ...)
messages |
A list into which to add the messages. |
sender |
A character value used as the |
dbname |
A character value giving the name of the database in
which to put the message. See |
dburi |
A character vector giving the URI for the database. See
|
messSet |
A character vector giving the message values of the messages
that will be processed. Messages whose |
colname |
The name of the database column into which the messages
will be sent. See |
targetField |
The name of the field that will be modified in the
database by the |
jsonEncoder |
A function that will be used to encode the data
object as JSON before it is set. See |
qfields |
The fields that will be used as a key when trying to
find matching messages in the database for the
|
name |
An object of class |
fieldlist |
A named |
... |
Other arguments passed to the constructor. |
The functions are as follows:
CaptureListener
Creates an object of class
CaptureListener
which stores the messages in
a list.
InjectionListener
Creates an object of class
InjectionListener
which inserts the message into
the designated database.
UpdateListener
Creates an object of class
UpdateListener
which updates the designated
field.
UpsertListener
Creates an object of class
UpsertListener
which insert or replaces the
message in the designated collection.
TableListener
Creates an object of class
TableListener
which adds details from message
to rows of a data frame.
See the class descriptions for more information.
An object of the virtual class Listener
.
Russell Almond
This is an example of the observer design pattern. https://en.wikipedia.org/wiki/Observer_pattern.
Listener
, P4Message
,
UpsertListener
,
UpdateListener
,
CaptureListener
,
InjectionListener
,
TableListener
,
ListenerSet
,
mongo
cl <- CaptureListener() il <- InjectionListener(sender="EI_app", dbname="EARecords",dburi="mongodb://localhost", colname="EvidenceSets",messSet="New Observables") upsl <- UpsertListener(sender="EI_app", dbname="EARecords",dburi="mongodb://localhost", colname="LatestEvidence",messSet="New Observables", qfields=c("app","uid")) trophy2json <- function(dat) { paste('{', '"trophyHall"', ':','[', paste( paste('{"',names(dat$trophyHall),'":"',dat$trophyHall,'"}', sep=""), collapse=", "), '],', '"bankBalance"', ':', dat$bankBalance, '}') } ul <- UpdateListener(dbname="Proc4",dburi="mongodb://localhost", colname="Players",targetField="data", messSet=c("Money Earned","Money Spent"), jsonEncoder="trophy2json") tabMaker <- TableListener(name="Trophy Table", messSet="New Observables", fieldlist=c(uid="character", context="character", timestamp="character", solvedtime="numeric", trophy="ordered(none,silver,gold)"))