public class AWSIotMessage extends Object implements AwsIotMessageCallback
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
.
Modifier and Type | Field and Description |
---|---|
protected AWSIotDeviceErrorCode |
errorCode
Error code for shadow methods.
|
protected String |
errorMessage
Error message for shadow methods.
|
protected byte[] |
payload
The payload of the message.
|
protected AWSIotQos |
qos
The MQTT QoS level for the message.
|
protected String |
topic
The topic the message is received from or published to.
|
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
AWSIotDeviceErrorCode |
getErrorCode()
Error code for shadow methods.
|
String |
getErrorMessage()
Error message for shadow methods.
|
byte[] |
getPayload()
Gets the byte array payload.
|
AWSIotQos |
getQos()
The MQTT QoS level for the message.
|
String |
getStringPayload()
Gets the string payload.
|
String |
getTopic()
The topic the message is received from or published to.
|
void |
onFailure()
Callback function to be invoked a non-block API has completed
unsuccessfully.
|
void |
onSuccess()
Callback function to be invoked a non-block API has completed
successfully.
|
void |
onTimeout()
Callback function to be invoked a non-block API has timed out.
|
void |
setErrorCode(AWSIotDeviceErrorCode errorCode)
Error code for shadow methods.
|
void |
setErrorMessage(String errorMessage)
Error message for shadow methods.
|
void |
setPayload(byte[] payload)
Sets the byte array payload.
|
void |
setQos(AWSIotQos qos)
The MQTT QoS level for the message.
|
void |
setStringPayload(String payload)
Sets the string payload.
|
void |
setTopic(String topic)
The topic the message is received from or published to.
|
protected String topic
protected AWSIotQos qos
protected byte[] payload
protected AWSIotDeviceErrorCode errorCode
protected String errorMessage
public AWSIotMessage(String topic, AWSIotQos qos)
topic
- the topic of the messageqos
- the QoS level of the messagepublic AWSIotMessage(String topic, AWSIotQos qos, byte[] payload)
topic
- the topic of the messageqos
- the QoS level of the messagepayload
- the payload of the messagepublic byte[] getPayload()
public void setPayload(byte[] payload)
payload
- the new byte array payloadpublic String getStringPayload()
public void setStringPayload(String payload)
payload
- the new string payloadpublic void onSuccess()
onSuccess
in interface AwsIotMessageCallback
public void onFailure()
onFailure
in interface AwsIotMessageCallback
public void onTimeout()
onTimeout
in interface AwsIotMessageCallback
public String getTopic()
public void setTopic(String topic)
topic
- the new topic of the messagepublic AWSIotQos getQos()
public void setQos(AWSIotQos qos)
qos
- the new QoS levelpublic AWSIotDeviceErrorCode getErrorCode()
public void setErrorCode(AWSIotDeviceErrorCode errorCode)
errorCode
- the new error code for the shadow methodpublic String getErrorMessage()
public void setErrorMessage(String errorMessage)
errorMessage
- the new error message for the shadow methodCopyright © 2020. All rights reserved.