public class AwsIotMqttConnection extends AwsIotConnection
AwsIotConnection
to provide the basic MQTT pub/sub
functionalities using the Paho MQTT library.client, connectionStatus
Constructor and Description |
---|
AwsIotMqttConnection(AbstractAwsIotClient client,
SocketFactory socketFactory,
String serverUri) |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection(AwsIotMessageCallback callback)
Abstract method which is called to terminate an underneath connection.
|
AwsIotMqttClientListener |
getClientListener() |
AwsIotMqttMessageListener |
getMessageListener() |
org.eclipse.paho.client.mqttv3.MqttAsyncClient |
getMqttClient() |
Set<String> |
getServerUris() |
SocketFactory |
getSocketFactory() |
void |
openConnection(AwsIotMessageCallback callback)
Abstract method which is called to establish an underneath connection.
|
void |
publishMessage(AWSIotMessage message)
Abstract method which is called to publish a message.
|
void |
setClientListener(AwsIotMqttClientListener clientListener) |
void |
setMessageListener(AwsIotMqttMessageListener messageListener) |
void |
setMqttClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient mqttClient) |
void |
subscribeTopic(AWSIotMessage message)
Abstract method which is called to subscribe to a topic.
|
void |
unsubscribeTopic(AWSIotMessage message)
Abstract method which is called to unsubscribe to a topic.
|
connect, disconnect, getClient, getConnectCallback, getConnectionStatus, getPublishQueue, getRetryTask, getRetryTimes, getSubscribeQueue, getUnsubscribeQueue, isUserDisconnect, onConnectionClosed, onConnectionFailure, onConnectionSuccess, publish, setConnectionStatus, subscribe, unsubscribe, updateCredentials
public AwsIotMqttConnection(AbstractAwsIotClient client, SocketFactory socketFactory, String serverUri) throws AWSIotException
AWSIotException
public void openConnection(AwsIotMessageCallback callback) throws AWSIotException
AwsIotConnection
openConnection
in class AwsIotConnection
callback
- connection callback functionsAWSIotException
- this exception is thrown when the request is failed to be
sentpublic void closeConnection(AwsIotMessageCallback callback) throws AWSIotException
AwsIotConnection
closeConnection
in class AwsIotConnection
callback
- connection callback functionsAWSIotException
- this exception is thrown when the request is failed to be
sentpublic void publishMessage(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
AwsIotConnection
publishMessage
in class AwsIotConnection
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 retriedpublic void subscribeTopic(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
AwsIotConnection
subscribeTopic
in class AwsIotConnection
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 retriedpublic void unsubscribeTopic(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
AwsIotConnection
unsubscribeTopic
in class AwsIotConnection
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 SocketFactory getSocketFactory()
public org.eclipse.paho.client.mqttv3.MqttAsyncClient getMqttClient()
public AwsIotMqttMessageListener getMessageListener()
public AwsIotMqttClientListener getClientListener()
public void setMqttClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient mqttClient)
public void setMessageListener(AwsIotMqttMessageListener messageListener)
public void setClientListener(AwsIotMqttClientListener clientListener)
Copyright © 2020. All rights reserved.