Class AWSIotMessage
java.lang.Object
com.amazonaws.services.iot.client.AWSIotMessage
- All Implemented Interfaces:
AwsIotMessageCallback
- Direct Known Subclasses:
AwsIotCompletion,AwsIotDeviceReportMessage,AwsIotDeviceSyncMessage,AWSIotTopic
A common data structure that is used in a lot of non-blocking APIs in this
library.
It provides common data elements, such as topic, qos, and
payload, used by the APIs.
It also contains callback functions that can be overridden to provide
customized handlers. The callback functions are invoked when a non-blocking
API call has completed successfully, unsuccessfully, or timed out.
Applications wish to have customized callback functions must extend this
class or its child classes, such as AWSIotTopic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AWSIotDeviceErrorCodeError code for shadow methods.protected StringError message for shadow methods.protected byte[]The payload of the message.protected AWSIotQosThe MQTT QoS level for the message.protected StringThe topic the message is received from or published to. -
Constructor Summary
ConstructorsConstructorDescriptionAWSIotMessage(String topic, AWSIotQos qos) Instantiates a new message object.AWSIotMessage(String topic, AWSIotQos qos, byte[] payload) Instantiates a new message object.AWSIotMessage(String topic, AWSIotQos qos, String payload) Instantiates a new message object. -
Method Summary
Modifier and TypeMethodDescriptionError code for shadow methods.Error message for shadow methods.byte[]Gets the byte array payload.getQos()The MQTT QoS level for the message.Gets the string payload.getTopic()The topic the message is received from or published to.voidCallback function to be invoked a non-block API has completed unsuccessfully.voidCallback function to be invoked a non-block API has completed successfully.voidCallback function to be invoked a non-block API has timed out.voidsetErrorCode(AWSIotDeviceErrorCode errorCode) Error code for shadow methods.voidsetErrorMessage(String errorMessage) Error message for shadow methods.voidsetPayload(byte[] payload) Sets the byte array payload.voidThe MQTT QoS level for the message.voidsetStringPayload(String payload) Sets the string payload.voidThe topic the message is received from or published to.
-
Field Details
-
topic
The topic the message is received from or published to. -
qos
The MQTT QoS level for the message. -
payload
protected byte[] payloadThe payload of the message. -
errorCode
Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs. -
errorMessage
Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.
-
-
Constructor Details
-
AWSIotMessage
Instantiates a new message object.- Parameters:
topic- the topic of the messageqos- the QoS level of the message
-
AWSIotMessage
Instantiates a new message object.- Parameters:
topic- the topic of the messageqos- the QoS level of the messagepayload- the payload of the message
-
AWSIotMessage
Instantiates a new message object.- Parameters:
topic- the topic of the messageqos- the QoS level of the messagepayload- the payload of the message
-
-
Method Details
-
getPayload
public byte[] getPayload()Gets the byte array payload.- Returns:
- the byte array payload
-
setPayload
public void setPayload(byte[] payload) Sets the byte array payload.- Parameters:
payload- the new byte array payload
-
getStringPayload
Gets the string payload.- Returns:
- the string payload
-
setStringPayload
Sets the string payload.- Parameters:
payload- the new string payload
-
onSuccess
public void onSuccess()Callback function to be invoked a non-block API has completed successfully.- Specified by:
onSuccessin interfaceAwsIotMessageCallback
-
onFailure
public void onFailure()Callback function to be invoked a non-block API has completed unsuccessfully.- Specified by:
onFailurein interfaceAwsIotMessageCallback
-
onTimeout
public void onTimeout()Callback function to be invoked a non-block API has timed out.- Specified by:
onTimeoutin interfaceAwsIotMessageCallback
-
getTopic
The topic the message is received from or published to.- Returns:
- the current topic of the message
-
setTopic
The topic the message is received from or published to.- Parameters:
topic- the new topic of the message
-
getQos
The MQTT QoS level for the message.- Returns:
- the current QoS level
-
setQos
The MQTT QoS level for the message.- Parameters:
qos- the new QoS level
-
getErrorCode
Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs.- Returns:
- the current error code of the shadow method
-
setErrorCode
Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs.- Parameters:
errorCode- the new error code for the shadow method
-
getErrorMessage
Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.- Returns:
- the current error message of the shadow method
-
setErrorMessage
Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.- Parameters:
errorMessage- the new error message for the shadow method
-