public class MqttConnectOptions extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
CLEAN_SESSION_DEFAULT
The default clean session setting if one is not specified
|
static int |
CONNECTION_TIMEOUT_DEFAULT
The default connection timeout in seconds if one is not specified
|
static int |
KEEP_ALIVE_INTERVAL_DEFAULT
The default keep alive interval in seconds if one is not specified
|
static int |
MQTT_VERSION_3_1 |
static int |
MQTT_VERSION_3_1_1 |
static int |
MQTT_VERSION_DEFAULT
The default MqttVersion is 3.1.1 first, dropping back to 3.1 if that fails
|
protected static int |
URI_TYPE_LOCAL |
protected static int |
URI_TYPE_SSL |
protected static int |
URI_TYPE_TCP |
Constructor and Description |
---|
MqttConnectOptions()
Constructs a new
MqttConnectOptions object using the
default values. |
Modifier and Type | Method and Description |
---|---|
int |
getConnectionTimeout()
Returns the connection timeout value.
|
org.eclipse.paho.client.mqttv3.util.Properties |
getDebug() |
int |
getKeepAliveInterval()
Returns the "keep alive" interval.
|
int |
getMqttVersion()
Returns the MQTT version.
|
char[] |
getPassword()
Returns the password to use for the connection.
|
String[] |
getServerURIs() |
org.eclipse.paho.client.mqttv3.util.Properties |
getSSLProperties()
Returns the SSL properties for the connection.
|
String |
getUserName()
Returns the user name to use for the connection.
|
String |
getWillDestination()
Returns the topic to be used for last will and testament (LWT).
|
MqttMessage |
getWillMessage()
Returns the message to be sent as last will and testament (LWT).
|
boolean |
isCleanSession()
Returns whether the server should remember state for the client across reconnects.
|
void |
setCleanSession(boolean cleanSession)
Sets whether the server should remember state for the client across reconnects.
|
void |
setConnectionTimeout(int connectionTimeout)
Sets the connection timeout value.
|
void |
setKeepAliveInterval(int keepAliveInterval)
Sets the "keep alive" interval.
|
void |
setMqttVersion(int MqttVersion)
Sets the MQTT version.
|
void |
setPassword(char[] password)
Sets the password to use for the connection.
|
void |
setServerURIs(String[] array) |
void |
setSSLProperties(org.eclipse.paho.client.mqttv3.util.Properties props)
Sets the SSL properties for the connection.
|
void |
setUserName(String userName)
Sets the user name to use for the connection.
|
void |
setWill(MqttTopic topic,
byte[] payload,
int qos,
boolean retained)
Sets the "Last Will and Testament" (LWT) for the connection.
|
void |
setWill(String topic,
byte[] payload,
int qos,
boolean retained)
Sets the "Last Will and Testament" (LWT) for the connection.
|
protected void |
setWill(String topic,
MqttMessage msg,
int qos,
boolean retained)
Sets up the will information, based on the supplied parameters.
|
String |
toString()
Returns a string representation of the object.
|
protected static int |
validateURI(String srvURI)
Validate a URI
|
public static final int KEEP_ALIVE_INTERVAL_DEFAULT
public static final int CONNECTION_TIMEOUT_DEFAULT
public static final boolean CLEAN_SESSION_DEFAULT
public static final int MQTT_VERSION_DEFAULT
public static final int MQTT_VERSION_3_1
public static final int MQTT_VERSION_3_1_1
protected static final int URI_TYPE_TCP
protected static final int URI_TYPE_SSL
protected static final int URI_TYPE_LOCAL
public MqttConnectOptions()
MqttConnectOptions
object using the
default values.
The defaults are:
public char[] getPassword()
public void setPassword(char[] password)
public String getUserName()
public void setUserName(String userName)
IllegalArgumentException
- if the user name is blank or only
contains whitespace characters.public void setWill(MqttTopic topic, byte[] payload, int qos, boolean retained)
topic
- the topic to publish to.payload
- the byte payload for the message.qos
- the quality of service to publish the message at (0, 1 or 2).retained
- whether or not the message should be retained.public void setWill(String topic, byte[] payload, int qos, boolean retained)
topic
- the topic to publish to.payload
- the byte payload for the message.qos
- the quality of service to publish the message at (0, 1 or 2).retained
- whether or not the message should be retained.protected void setWill(String topic, MqttMessage msg, int qos, boolean retained)
public int getKeepAliveInterval()
setKeepAliveInterval(int)
public int getMqttVersion()
setMqttVersion(int)
public void setKeepAliveInterval(int keepAliveInterval) throws IllegalArgumentException
The default value is 60 seconds
keepAliveInterval
- the interval, measured in seconds, must be >= 0.IllegalArgumentException
public int getConnectionTimeout()
setConnectionTimeout(int)
public void setConnectionTimeout(int connectionTimeout)
connectionTimeout
- the timeout value, measured in seconds. It must be >0;public String getWillDestination()
null
if LWT is not set.setWill(MqttTopic, byte[], int, boolean)
public MqttMessage getWillMessage()
IllegalStateException
being thrown.null
if LWT is not set.public org.eclipse.paho.client.mqttv3.util.Properties getSSLProperties()
public void setSSLProperties(org.eclipse.paho.client.mqttv3.util.Properties props)
#setSocketFactory(SocketFactory)
.
The following properties can be used:
com.ibm.micro.security.Password.obfuscate(char[] password)
.
This obfuscates the password using a simple and insecure XOR and Base64
encoding mechanism. Note that this is only a simple scrambler to
obfuscate clear-text passwords.com.ibm.micro.security.Password.obfuscate(char[] password)
.
This obfuscates the password using a simple and insecure XOR and Base64
encoding mechanism. Note that this is only a simple scrambler to
obfuscate clear-text passwords.public boolean isCleanSession()
public void setCleanSession(boolean cleanSession)
public String[] getServerURIs()
public void setServerURIs(String[] array)
array
- of serverURIsprotected static int validateURI(String srvURI)
srvURI
- public void setMqttVersion(int MqttVersion) throws IllegalArgumentException
MqttVersion
- the version of the MQTT protocol.IllegalArgumentException
public org.eclipse.paho.client.mqttv3.util.Properties getDebug()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())