public class MqttConnectOptions extends Object
Modifier and Type | Field and Description |
---|---|
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_1
Mqtt Version 3.1.1.
|
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 in seconds.
|
int |
getKeepAliveInterval()
Returns the "keep alive" interval.
|
int |
getMqttVersion()
Returns the MQTT version.
|
char[] |
getPassword()
Returns the password to use for the connection.
|
SocketFactory |
getSocketFactory()
Returns the socket factory that will be used when connecting, or
null if one has not been set. |
String |
getUserName()
Returns the user name to use for the connection.
|
boolean |
isCleanSession()
Returns whether the client and 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 |
setPassword(char[] password)
Sets the password to use for the connection.
|
void |
setSocketFactory(SocketFactory socketFactory)
Sets the
SocketFactory to use. |
void |
setUserName(String userName)
Sets the user name to use for the connection.
|
public static final int CONNECTION_TIMEOUT_DEFAULT
public static final int KEEP_ALIVE_INTERVAL_DEFAULT
public static final int MQTT_VERSION_3_1_1
public MqttConnectOptions()
MqttConnectOptions
object using the default values.
The defaults are:
public int getConnectionTimeout()
setConnectionTimeout(int)
public int getKeepAliveInterval()
setKeepAliveInterval(int)
public int getMqttVersion()
@Nullable public char[] getPassword()
null
if no password is required for the
connection. Important Note : The returned char array is not cloned for memory efficiency reasons.
Be careful with it.@Nullable public SocketFactory getSocketFactory()
null
if one has not been set.@Nullable public String getUserName()
null
if no password is required for the
connection.public boolean isCleanSession()
public void setConnectionTimeout(int connectionTimeout)
connectionTimeout
- the timeout value, measured in seconds. It must be >0;public void setKeepAliveInterval(int keepAliveInterval) throws IllegalArgumentException
The default value is 60 seconds
keepAliveInterval
- the interval, measured in seconds, must be >= 0.IllegalArgumentException
- if the keepAliveInterval was invalidpublic void setPassword(char[] password)
password
- A Char Array of the password. Important Note : The char array is not cloned for memory
efficiency reasons. Be careful with it.public void setSocketFactory(SocketFactory socketFactory)
SocketFactory
to use. This allows an application to apply its own policies around the
creation of network sockets. If using an SSL connection, an SSLSocketFactory
can be used to supply
application-specific security settings.socketFactory
- the factory to use.public void setUserName(String userName)
userName
- The Username as a String