A JavaScript abstraction for the Persistent Publish/Subscribe (PPS). The JPPS
module is required to use this module. Content that's passed through the
this object are returned as JSON-encoded strings.
Your applications can use this module to access the PPS objects used by platform services. You must provide the location or filesystem path of the underlying PPS object that you want to access. Then, you can update and retrieve attributes in that PPS object.
Members
-
data
-
(Read-only) Get the data that was read from the PPS object. -
mode
-
(Read-only) Get the mode for the current PPS object. -
path
-
(Read-only) Get the path to the PPS object.
Methods
-
close()
-
Close the connection to the PPS object. -
create(ppsPath, ppsMode) → {Object}
-
Creates the specified PPS object. If the object exists, no error occurs.Parameters:
Name Type Description ppsPathString The path of the PPS object. ppsModePPSMode The mode used to open the PPS object. Returns:
An instance of a PPS object to perform operations on.- Type
- Object
Example
mypps.create("/pps/qnxcar/myapp", pps.PPSMode.DELTA) -
deactivate()
-
Close the connection to the PPS object. -
isActive()
-
Determine whether the connection the PPS object is active.Returns:
A value oftrueto indicate whether the PPS object connection is active. -
onEvent(id, type, data)
-
The event to change occurs to the PPS object.Parameters:
Name Type Description idString The ID to the PPS object. typeString The type of event that fires. The events are: - onFirstReadComplete
- onNewData
- onOpenFailed
- onWriteFailed
dataObject The data to update when the specified event is triggered. -
onFirstReadComplete()
-
Callback that's fired when the PPS object is first read afteropen()is called. -
onNewData()
-
Callback that's fired when new data has changed in the PPS that you have open. -
onOpenFailed(message)
-
Callback called when opening the PPS object fails.Parameters:
Name Type Description messageString The message to output in the log. -
onWriteFailed(message)
-
Callback called when writing to the PPS object fails.Parameters:
Name Type Description messageString The message to output in the log. -
open(fileMode, options)
-
Open the connection to the PPS object.Parameters:
Name Type Description fileModeFileMode The mode to use to open the PPS object. optionsArray.<Object> Additional parameters to pass to the open -
write(data)
-
Write values to the PPS object.Parameters:
Name Type Description dataObject The data (as a map, i.e., ({a:2, b:3})) to write to the PPS object as key-value pair.Example
var data = {}; data[key] = value; mypps.write(data);
Type Definitions
-
FileMode
-
The modes to open a PPS object with using theopen()function. CREATE can be bitwise OR'ed with RDONLY, WRONLY, or RDWR.Properties:
>Name Type Description RDONLYNumber Open the PPS object for read-only. WRONLYNumber Open the PPS object for write-only. This mode is the fast mode. RDWRNumber Open the PPS object for read-write. CREATENumber Create a PPS object and open it for read-write. The creation of the PPS object occurs if it doesn't exist, otherwise, the PPS object is opened for read-write. Example
open("/pps/someppsobject", FileMode.CREATE|FileMode.WRONLY) -
PPSMode
-
The Persistent Publish/Subscribe subscription mode to use.Properties:
>Name Type Description FULLNumber A subscriber mode that indicates to receive a single, consistent version of the entire PPS object as it exists at the time it's requested. DELTANumber A subscriber receives only the changes of all attributes since the last time a read request was made. On the first read, all the changes are sent because the subscriber knows nothing about the state of the object. SERVERNumber Do not use. Designate your application as a server for a particular PPS object. This mode makes your application a critical publisher of the object. Your application will also receive notifications in DELTA mode. RAWNumber Do not use. A raw value from PPS that's not a JSON-encoded string.