new MessageDispatcher(dcdUtil)
There can be only one MessageDispatcher instance per DirectlyConnectedDevice at a time and it is created at first use. To close an instance of a MessageDispatcher the DirectlyConnectedDevice.close method must be used.
The message dispatcher uses the RequestDispatcher for dispatching automatically request messages that come from the server and generate response messages to the server.
The onDelivery and onError attributes can be used to set handlers that are called when messages
are successfully delivered or an error occurs:
messageDispatcher.onDelivery = function (messages);
messageDispatcher.onError = function (messages, error);
Where messages is an array of the iotcs.message.Message object representing the messages that
were sent or not and error is an Error object.
Also the MessageDispatcher implements the message dispatcher, diagnostics and connectivity test capabilities.
Parameters:
Name | Type | Description |
---|---|---|
dcdUtil |
iotcs.device.util.DirectlyConnectedDevice | The directly connected device (Messaging API) associated with this message dispatcher. |
- See:
-
iotcs.message.Message
iotcs.message.Message.Priority
iotcs.device.util.RequestDispatcher
iotcs.device.util.DirectlyConnectedDevice#close
Members
(nullable) onDeliveryCallback :iotcs.device.util.MessageDispatcher~onDeliveryCallback
Type:
Methods
(static) getRequestDispatcher() → {iotcs.device.util.RequestDispatcher}
Returns:
(static) offer(message)
Parameters:
Name | Type | Description |
---|---|---|
message |
iotcs.message.Message | The message to be offered. |
Throws:
-
Error if all the messages cannot be added to the queue.
-
Error if
messages
isnull
or empty.
Type Definitions
onDeliveryCallback(An)
Parameters:
Name | Type | Description |
---|---|---|
An |
Array.<iotcs.message.Message> | array of the iotcs.message.Message's representing the messages that were sent. |