public abstract class AbstractClient extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String |
CLIENT_ID_DELIMITER |
protected AbstractConfig |
config |
static long |
DEFAULT_ACTION_TIMEOUT |
static int |
DEFAULT_DISCONNECTED_BUFFER_SIZE |
static int |
DEFAULT_MAX_CONNECT_ATTEMPTS |
static int |
DEFAULT_MAX_INFLIGHT_MESSAGES |
static int |
DEFAULT_MESSAGING_QOS |
protected boolean |
disconnectRequested |
protected static com.google.gson.Gson |
gson |
protected int |
messageCount |
protected org.eclipse.paho.client.mqttv3.MqttAsyncClient |
mqttAsyncClient |
protected org.eclipse.paho.client.mqttv3.MqttCallback |
mqttCallback |
protected org.eclipse.paho.client.mqttv3.MqttClient |
mqttClient |
protected org.eclipse.paho.client.mqttv3.MqttConnectOptions |
mqttClientOptions |
protected org.eclipse.paho.client.mqttv3.persist.MemoryPersistence |
persistence |
| Constructor and Description |
|---|
AbstractClient(AbstractConfig config)
Note that this class does not have a default constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close and free all MQTT client resources
|
protected void |
configureMqttClient(org.eclipse.paho.client.mqttv3.MqttCallbackExtended callback)
configureMqtt() is called when the User does not provide an Organization value and intends
to connect to Watson IoT Platform using the QUICKSTART mode.
|
void |
connect()
Connects the device to IBM Watson IoT Platform and retries when there is an exception
based on the value set in retry parameter.
|
void |
disconnect()
Disconnect the device from the IBM Watson IoT Platform
|
AbstractConfig |
getConfig() |
boolean |
isConnected()
Determine whether this device is currently connected to the IBM Watson Internet
of Things Platform.
|
String |
toString()
Provides a human readable String representation of this Device, including the number
of messages sent and the current connect status.
|
public static final int DEFAULT_MAX_CONNECT_ATTEMPTS
public static final long DEFAULT_ACTION_TIMEOUT
public static final int DEFAULT_MAX_INFLIGHT_MESSAGES
public static final int DEFAULT_MESSAGING_QOS
public static final int DEFAULT_DISCONNECTED_BUFFER_SIZE
protected static final String CLIENT_ID_DELIMITER
protected volatile boolean disconnectRequested
protected static final com.google.gson.Gson gson
protected AbstractConfig config
protected int messageCount
protected org.eclipse.paho.client.mqttv3.MqttAsyncClient mqttAsyncClient
protected org.eclipse.paho.client.mqttv3.MqttConnectOptions mqttClientOptions
protected org.eclipse.paho.client.mqttv3.MqttCallback mqttCallback
protected org.eclipse.paho.client.mqttv3.MqttClient mqttClient
protected org.eclipse.paho.client.mqttv3.persist.MemoryPersistence persistence
public AbstractClient(AbstractConfig config)
config - Configuration object for the clientpublic void connect()
throws org.eclipse.paho.client.mqttv3.MqttException,
KeyManagementException,
NoSuchAlgorithmException
Connects the device to IBM Watson IoT Platform and retries when there is an exception
based on the value set in retry parameter.
This method does not retry when the following exceptions occur.
org.eclipse.paho.client.mqttv3.MqttException - One or more credentials are wrongNoSuchAlgorithmException - Problems with TLSKeyManagementException - Problems with TLSprotected void configureMqttClient(org.eclipse.paho.client.mqttv3.MqttCallbackExtended callback)
throws KeyManagementException,
NoSuchAlgorithmException
callback - The handler for MQTT callbacksNoSuchAlgorithmException - Problems with TLSKeyManagementException - Problems with TLSpublic void disconnect()
public void close()
throws org.eclipse.paho.client.mqttv3.MqttException
org.eclipse.paho.client.mqttv3.MqttException - Thrown if an error occurspublic boolean isConnected()
public AbstractConfig getConfig()
Copyright © 2019. All rights reserved.