MessageCollection objects are used in JavaScript filters to manage collections of Message objects. There are two types of instances of the MessageCollection
object:
input
- an array that represents messages that are received by the filter.output
- an array that represents messages that are sent by the filter.
Properties
Property |
Description |
---|---|
length |
Returns the number of messages in the collection |
Methods
Method |
Description |
---|---|
|
Makes a copy of the template message and appends it to the end of the collection. The copied message object is also returned to the caller. |
|
Removes the message from the collection at the given index. The index is zero-based. |
|
Returns the Message object at the given index in the collection. The index is zero-based. |
Example
The output
object in a JavaScript filter is an instance of MessageCollection
. The append()
method is used to add an input message to the collection of messages that will be output. The next object that is returned is an instance of Message, so using this reference the message can be altered using the Message methods.
for (var i = 0; i < input.length; i++) { // Append a copy of the read-only input message to the output MessageCollection var next = output.append(input[i]); //... }