public class AwsIotCompletion extends AWSIotMessage
Modifier and Type | Field and Description |
---|---|
protected boolean |
hasFailure
Indicates whether the request has completed with failure.
|
protected boolean |
hasSuccess
Indicates whether the request has completed successfully.
|
protected boolean |
hasTimeout
Indicates whether the request has timed out.
|
protected boolean |
isAsync
whether the request is asynchronous or not.
|
protected AWSIotMessage |
request
The request containing the callback functions.
|
protected long |
timeout
The timeout associated with the request.
|
protected Future<?> |
timeoutTask
The future object of the timeout task.
|
errorCode, errorMessage, payload, qos, topic
Constructor and Description |
---|
AwsIotCompletion(AWSIotMessage req,
long timeout,
boolean isAsync)
Instantiates a new completion object either synchronous or asynchronous
request based on the
isAsync argument. |
AwsIotCompletion(long timeout,
boolean isAsync)
Instantiates a new completion object either synchronous or asynchronous
request based on the
isAsync argument. |
AwsIotCompletion(String topic,
AWSIotQos qos,
byte[] payload,
long timeout)
Instantiates a new completion object with a synchronous request.
|
AwsIotCompletion(String topic,
AWSIotQos qos,
long timeout)
Instantiates a new completion object with a synchronous request.
|
AwsIotCompletion(String topic,
AWSIotQos qos,
String payload,
long timeout)
Instantiates a new completion object with a synchronous request.
|
Modifier and Type | Method and Description |
---|---|
void |
get(AbstractAwsIotClient client)
The user of the completion object is expected to call this function to
either block until the request is completed or timed out in the case of
synchronous calls, or to schedule a timeout handler in the case of
asynchronous calls.
|
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.
|
getErrorCode, getErrorMessage, getPayload, getQos, getStringPayload, getTopic, setErrorCode, setErrorMessage, setPayload, setQos, setStringPayload, setTopic
protected final AWSIotMessage request
protected final long timeout
protected final boolean isAsync
protected Future<?> timeoutTask
protected boolean hasSuccess
protected boolean hasFailure
protected boolean hasTimeout
public AwsIotCompletion(String topic, AWSIotQos qos, long timeout)
topic
- the topic of the requestqos
- the QoS of the requesttimeout
- the timeout in milliseconds for the request. If timeout is 0
or less, the request will never be timed out.public AwsIotCompletion(String topic, AWSIotQos qos, String payload, long timeout)
topic
- the topic of the requestqos
- the QoS of the requestpayload
- the string payload of the requesttimeout
- the timeout in milliseconds for the request. If timeout is 0
or less, the request will never be timed out.public AwsIotCompletion(String topic, AWSIotQos qos, byte[] payload, long timeout)
topic
- the topic of the requestqos
- the QoS of the requestpayload
- the byte array payload of the requesttimeout
- the timeout in milliseconds for the request. If timeout is 0
or less, the request will never be timed out.public AwsIotCompletion(long timeout, boolean isAsync)
isAsync
argument.timeout
- the timeout in milliseconds for the request. If timeout is 0
or less, the request will never be timed out.isAsync
- whether or not the request is asynchronouspublic AwsIotCompletion(AWSIotMessage req, long timeout, boolean isAsync)
isAsync
argument. Callback functions
are provided through the req
argument.req
- the request containing request topic, QoS, payload, and
callback functions for asynchronous requests.timeout
- the timeout in milliseconds for the request. If timeout is 0
or less, the request will never be timed out.isAsync
- whether or not the request is asynchronouspublic void get(AbstractAwsIotClient client) throws AWSIotException, AWSIotTimeoutException
client
- the client object that provides the execution thread pool for
the timeout handler.AWSIotException
- For synchronous calls, this exception may be thrown if the
request has failed.AWSIotTimeoutException
- For synchronous calls, this exception may be thrown if the
request has timed out.public void onSuccess()
AWSIotMessage
onSuccess
in interface AwsIotMessageCallback
onSuccess
in class AWSIotMessage
public void onFailure()
AWSIotMessage
onFailure
in interface AwsIotMessageCallback
onFailure
in class AWSIotMessage
public void onTimeout()
AWSIotMessage
onTimeout
in interface AwsIotMessageCallback
onTimeout
in class AWSIotMessage
Copyright © 2020. All rights reserved.