new MessageEnumerator(client)
A class that implements a way of getting the history of all messages from the cloud and also
register listeners to the messages received.
Parameters:
Name | Type | Description |
---|---|---|
client |
iotcs.enterprise.EnterpriseClient | The enterprise client associated with the application context of the messages that need to be enumerated or listened to. |
Methods
(static) getMessages(deviceIdopt, nullable, messageTypeopt, nullable, expandopt, nullable, sinceopt, nullable, untilopt, nullable) → {iotcs.enterprise.Pageable}
Return a list of messages according to the given parameters. The method will generate a query
and make a request to the cloud and a list of messages will be returned based on the query in
descendant order of arrival of the messages to the cloud.
The query for messages must be made based on one of the following criteria or both:
- "device": messages from a specific device
- "type": messages of a given type
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deviceId |
string |
<optional> <nullable> |
The ID of the device as the source of the messages from the
enumerator. If this is null the messages for all devices will be enumerated. |
messageType |
string |
<optional> <nullable> |
The type of the messages to be enumerated. If this is
null then messages of all types will be enumerated. The only types are:
['DATA', 'ALERT', 'REQUEST', 'RESPONSE', 'WAKEUP', 'UPDATE_BUNDLE', 'RESOURCES_REPORT']. |
expand |
boolean |
<optional> <nullable> |
A flag that would say if the messages in the response contains expanded data. If this is not present the value is false. |
since |
number |
<optional> <nullable> |
The timestamp in milliseconds since EPOC that would represent that minimum time when the messages were received. |
until |
number |
<optional> <nullable> |
The timestamp in milliseconds since EPOC that would represent that maximum time when the messages were received. |
Returns:
A pageable instance with which pages can be requested that
contain messages as items.
(static) setListener(deviceIdopt, messageTypeopt, callback)
Registers a callback method to be called when new messages of a given type and/or for a given
device are received.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deviceId |
string |
<optional> |
The ID of the device for which the callback is called when new messages arrives. If this is null the callback will be called when messages for any device arrives. |
messageType |
string |
<optional> |
The type of the messages that the listener listens to. The types
are described in the getMessages method. If this is null the callback will be
called for all message types. |
callback |
function | The callback function that will be called when a new message from the associated device is received. |
- See:
-
iotcs.enterprise.MessageEnumerator#getMessages
(static) unsetListener(deviceIdopt, messageTypeopt)
The library will no longer monitor messages for the specified device and/or message type.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deviceId |
string |
<optional> |
The ID of the device for which the monitoring of messages will be stopped. |
messageType |
string |
<optional> |
The type of messages for which the monitoring will be stopped. The types are described in the getMessages method. |
- See:
-
iotcs.enterprise.MessageEnumerator#getMessages