Class MqttOptions
java.lang.Object
com.codename1.io.mqtt.MqttOptions
Everything an
MqttClient needs to open and identify a connection.
The setters return this.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncleanSession(boolean cleanSession) Sets the clean session flag (default true).connectTimeoutMillis(int millis) Sets the connect timeout in milliseconds (default 15000).credentials(String username, byte[] password) Sets the credentials.The client identifier.intThe time allowed for the transport to open and the broker to answer the CONNECT, in milliseconds.intThe keep alive interval in seconds; 0 disables it.intThe largest packet, in bytes after the fixed header, the client accepts.byte[]The password bytes, or null.getUri()The broker URI.The user name, or null.byte[]The will payload, or null when there is no will.intThe will QoS.The will topic, or null.booleanWhether the broker should discard any session state of this client id.booleanThe will retain flag.keepAliveSeconds(int seconds) Sets the keep alive interval in seconds (default 60, 0 to 65535).maxPacketSize(int bytes) Sets the largest incoming packet accepted (default 1 MiB, at most the protocol's 268435455).Sets the will the broker publishes if this client vanishes.
-
Constructor Details
-
MqttOptions
Creates options.
Parameters
-
uri:tcp://host[:port](default port 1883),ws://host[:port]/pathorwss://host[:port]/path, the last two over a WebSocket with themqttsubprotocol -
clientId: the client identifier; may be empty only with a clean session, in which case the broker assigns one
-
-
-
Method Details
-
getUri
The broker URI. -
getClientId
The client identifier. -
isCleanSession
public boolean isCleanSession()Whether the broker should discard any session state of this client id. -
cleanSession
Sets the clean session flag (default true). With false, the client keeps unacknowledged QoS 1 publishes across a reconnect and re-sends them with the DUP flag. -
getKeepAliveSeconds
public int getKeepAliveSeconds()The keep alive interval in seconds; 0 disables it. -
keepAliveSeconds
Sets the keep alive interval in seconds (default 60, 0 to 65535). -
getUsername
The user name, or null. -
getPassword
public byte[] getPassword()The password bytes, or null. The array is not copied. -
credentials
Sets the credentials. MQTT 3.1.1 allows a password only with a user name.
Parameters
-
username: the user name, or null for none -
password: the password, or null for none
-
-
will
Sets the will the broker publishes if this client vanishes.
Parameters
-
topic: the will topic, or null to clear the will -
payload: the will message -
qos: 0 or 1 -
retain: whether the broker retains the will
-
-
getWillTopic
The will topic, or null. -
getWillPayload
public byte[] getWillPayload()The will payload, or null when there is no will. -
getWillQos
public int getWillQos()The will QoS. -
isWillRetain
public boolean isWillRetain()The will retain flag. -
getConnectTimeoutMillis
public int getConnectTimeoutMillis()The time allowed for the transport to open and the broker to answer the CONNECT, in milliseconds. -
connectTimeoutMillis
Sets the connect timeout in milliseconds (default 15000). -
getMaxPacketSize
public int getMaxPacketSize()The largest packet, in bytes after the fixed header, the client accepts. -
maxPacketSize
Sets the largest incoming packet accepted (default 1 MiB, at most the protocol's 268435455). A larger one fails the connection.
-