public abstract class AwsIotConnection extends Object implements AwsIotConnectionCallback
Modifier and Type | Field and Description |
---|---|
protected AbstractAwsIotClient |
client
The client the connection is associated with.
|
protected AWSIotConnectionStatus |
connectionStatus
The connection status.
|
Constructor and Description |
---|
AwsIotConnection(AbstractAwsIotClient client)
Instantiates a new connection object.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
closeConnection(AwsIotMessageCallback callback)
Abstract method which is called to terminate an underneath connection.
|
void |
connect(AwsIotMessageCallback callback)
The actual connect method exposed by this class.
|
void |
disconnect(AwsIotMessageCallback callback)
The actual disconnect method exposed by this class.
|
AbstractAwsIotClient |
getClient()
The client the connection is associated with.
|
AwsIotMessageCallback |
getConnectCallback()
The callback functions for the connect request.
|
AWSIotConnectionStatus |
getConnectionStatus()
The connection status.
|
ConcurrentLinkedQueue<AWSIotMessage> |
getPublishQueue()
The offline publish queue holding messages while the connection is being
established.
|
Future<?> |
getRetryTask()
The future object holding the retry task.
|
int |
getRetryTimes()
The retry times.
|
ConcurrentLinkedQueue<AWSIotMessage> |
getSubscribeQueue()
The offline subscribe request queue holding messages while the connection
is being established.
|
ConcurrentLinkedQueue<AWSIotMessage> |
getUnsubscribeQueue()
The offline unsubscribe request queue holding messages while the
connection is being established.
|
boolean |
isUserDisconnect()
Flag to indicate user disconnect is in progress.
|
void |
onConnectionClosed()
On connection closed.
|
void |
onConnectionFailure()
On connection failure.
|
void |
onConnectionSuccess()
On connection success.
|
protected abstract void |
openConnection(AwsIotMessageCallback callback)
Abstract method which is called to establish an underneath connection.
|
void |
publish(AWSIotMessage message)
The actual publish method exposed by this class.
|
protected abstract void |
publishMessage(AWSIotMessage message)
Abstract method which is called to publish a message.
|
void |
setConnectionStatus(AWSIotConnectionStatus connectionStatus)
The connection status.
|
void |
subscribe(AWSIotMessage message)
The actual subscribe method exposed by this class.
|
protected abstract void |
subscribeTopic(AWSIotMessage message)
Abstract method which is called to subscribe to a topic.
|
void |
unsubscribe(AWSIotMessage message)
The actual unsubscribe method exposed by this class.
|
protected abstract void |
unsubscribeTopic(AWSIotMessage message)
Abstract method which is called to unsubscribe to a topic.
|
void |
updateCredentials(String awsAccessKeyId,
String awsSecretAccessKey,
String sessionToken)
Updates credentials for the connection, which will be used for new
connections.
|
protected AbstractAwsIotClient client
protected AWSIotConnectionStatus connectionStatus
public AwsIotConnection(AbstractAwsIotClient client)
client
- the clientprotected abstract void openConnection(AwsIotMessageCallback callback) throws AWSIotException
callback
- connection callback functionsAWSIotException
- this exception is thrown when the request is failed to be
sentprotected abstract void closeConnection(AwsIotMessageCallback callback) throws AWSIotException
callback
- connection callback functionsAWSIotException
- this exception is thrown when the request is failed to be
sentprotected abstract void publishMessage(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
message
- the message to be publishedAWSIotException
- this exception is thrown when there's an unrecoverable error
happened while processing the requestAwsIotRetryableException
- this exception is thrown when the request is failed to be
sent, which will be queued and retriedprotected abstract void subscribeTopic(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
message
- the topic to be subscribed toAWSIotException
- this exception is thrown when there's an unrecoverable error
happened while processing the requestAwsIotRetryableException
- this exception is thrown when the request is failed to be
sent, which will be queued and retriedprotected abstract void unsubscribeTopic(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
message
- the topic to be unsubscribed toAWSIotException
- this exception is thrown when there's an unrecoverable error
happened while processing the requestAwsIotRetryableException
- this exception is thrown when the request is failed to be
sent, which will be queued and retriedpublic void publish(AWSIotMessage message) throws AWSIotException
message
- the message to be publishedAWSIotException
- this exception is thrown when the underneath failed to
process the requestpublic void updateCredentials(String awsAccessKeyId, String awsSecretAccessKey, String sessionToken)
awsAccessKeyId
- the AWS access key idawsSecretAccessKey
- the AWS secret access keysessionToken
- Session token received along with the temporary credentials
from services like STS server, AssumeRole, or Amazon Cognito.public void subscribe(AWSIotMessage message) throws AWSIotException
message
- the topic to be subscribed toAWSIotException
- this exception is thrown when the underneath failed to
process the requestpublic void unsubscribe(AWSIotMessage message) throws AWSIotException
message
- the topic to be unsubscribed toAWSIotException
- this exception is thrown when the underneath failed to
process the requestpublic void connect(AwsIotMessageCallback callback) throws AWSIotException
callback
- user callback functionsAWSIotException
- this exception is thrown when the underneath layer failed to
process the requestpublic void disconnect(AwsIotMessageCallback callback) throws AWSIotException
callback
- user callback functionsAWSIotException
- this exception is thrown when the underneath layer failed to
process the requestpublic void onConnectionSuccess()
AwsIotConnectionCallback
onConnectionSuccess
in interface AwsIotConnectionCallback
public void onConnectionFailure()
AwsIotConnectionCallback
onConnectionFailure
in interface AwsIotConnectionCallback
public void onConnectionClosed()
AwsIotConnectionCallback
onConnectionClosed
in interface AwsIotConnectionCallback
public AbstractAwsIotClient getClient()
public AWSIotConnectionStatus getConnectionStatus()
public void setConnectionStatus(AWSIotConnectionStatus connectionStatus)
connectionStatus
- the new connection statuspublic Future<?> getRetryTask()
public int getRetryTimes()
public AwsIotMessageCallback getConnectCallback()
public boolean isUserDisconnect()
public ConcurrentLinkedQueue<AWSIotMessage> getPublishQueue()
public ConcurrentLinkedQueue<AWSIotMessage> getSubscribeQueue()
public ConcurrentLinkedQueue<AWSIotMessage> getUnsubscribeQueue()
Copyright © 2020. All rights reserved.