Class AWSIotMessage
- java.lang.Object
-
- com.amazonaws.services.iot.client.AWSIotMessage
-
- All Implemented Interfaces:
AwsIotMessageCallback
- Direct Known Subclasses:
AwsIotCompletion,AwsIotDeviceReportMessage,AwsIotDeviceSyncMessage,AWSIotTopic
public class AWSIotMessage extends Object implements AwsIotMessageCallback
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, andpayload, 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
Fields Modifier and Type Field Description protected AWSIotDeviceErrorCodeerrorCodeError code for shadow methods.protected StringerrorMessageError message for shadow methods.protected byte[]payloadThe payload of the message.protected AWSIotQosqosThe MQTT QoS level for the message.protected StringtopicThe topic the message is received from or published to.
-
Constructor Summary
Constructors Constructor Description AWSIotMessage(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AWSIotDeviceErrorCodegetErrorCode()Error code for shadow methods.StringgetErrorMessage()Error message for shadow methods.byte[]getPayload()Gets the byte array payload.AWSIotQosgetQos()The MQTT QoS level for the message.StringgetStringPayload()Gets the string payload.StringgetTopic()The topic the message is received from or published to.voidonFailure()Callback function to be invoked a non-block API has completed unsuccessfully.voidonSuccess()Callback function to be invoked a non-block API has completed successfully.voidonTimeout()Callback 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.voidsetQos(AWSIotQos qos)The MQTT QoS level for the message.voidsetStringPayload(String payload)Sets the string payload.voidsetTopic(String topic)The topic the message is received from or published to.
-
-
-
Field Detail
-
topic
protected String topic
The topic the message is received from or published to.
-
qos
protected AWSIotQos qos
The MQTT QoS level for the message.
-
payload
protected byte[] payload
The payload of the message.
-
errorCode
protected AWSIotDeviceErrorCode errorCode
Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs.
-
errorMessage
protected String errorMessage
Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.
-
-
Constructor Detail
-
AWSIotMessage
public AWSIotMessage(String topic, AWSIotQos qos)
Instantiates a new message object.- Parameters:
topic- the topic of the messageqos- the QoS level of the message
-
AWSIotMessage
public AWSIotMessage(String topic, AWSIotQos qos, byte[] payload)
Instantiates a new message object.- Parameters:
topic- the topic of the messageqos- the QoS level of the messagepayload- the payload of the message
-
-
Method Detail
-
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
public String getStringPayload()
Gets the string payload.- Returns:
- the string payload
-
setStringPayload
public void setStringPayload(String payload)
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
public String getTopic()
The topic the message is received from or published to.- Returns:
- the current topic of the message
-
setTopic
public void setTopic(String topic)
The topic the message is received from or published to.- Parameters:
topic- the new topic of the message
-
getQos
public AWSIotQos getQos()
The MQTT QoS level for the message.- Returns:
- the current QoS level
-
setQos
public void setQos(AWSIotQos qos)
The MQTT QoS level for the message.- Parameters:
qos- the new QoS level
-
getErrorCode
public AWSIotDeviceErrorCode 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
public void setErrorCode(AWSIotDeviceErrorCode errorCode)
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
public String 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
public void setErrorMessage(String errorMessage)
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
-
-