Class MqttWillAndTestament
java.lang.Object
org.openhab.core.io.transport.mqtt.MqttWillAndTestament
Class encapsulating the last will and testament that is published after the client has gone offline.
- Author:
- Markus Mann - Initial contribution
-
Constructor Summary
ConstructorDescriptionMqttWillAndTestament
(String topic, byte @Nullable [] payload, int qos, boolean retain) Create a newMqttWillAndTestament
with at least a topic name. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable MqttWillAndTestament
fromString
(@Nullable String string) Create an instance of the last will using a string with the following format:
topic:message:qos:retained
Where topic is a normal topic string (no placeholders are allowed) message the message to send qos Valid values are 0 (Deliver at most once),1 (Deliver at least once) or 2 retain true if messages shall be retainedstatic @Nullable MqttWillAndTestament
fromString
(@Nullable String string, @Nullable String topic, byte @Nullable [] payload, @Nullable Integer qos, @Nullable Boolean retain) byte @Nullable []
int
getQos()
getTopic()
boolean
isRetain()
toString()
-
Constructor Details
-
MqttWillAndTestament
Create a newMqttWillAndTestament
with at least a topic name.- Parameters:
topic
- topic is a normal topic string (no placeholders are allowed)payload
- The optional payload. Can be null.qos
- Valid values are 0 (Deliver at most once),1 (Deliver at least once) or 2
retain
- true if messages shall be retained
-
Method Details
-
fromString
Create an instance of the last will using a string with the following format:
topic:message:qos:retained
Where- topic is a normal topic string (no placeholders are allowed)
- message the message to send
- qos Valid values are 0 (Deliver at most once),1 (Deliver at least once) or 2
- retain true if messages shall be retained
- Parameters:
string
- the string to parse. If null, null is returned- Returns:
- the will instance, will be null only if parameter is null
-
fromString
public static @Nullable MqttWillAndTestament fromString(@Nullable String string, @Nullable String topic, byte @Nullable [] payload, @Nullable Integer qos, @Nullable Boolean retain) -
getTopic
- Returns:
- the topic for the last will.
-
getPayload
public byte @Nullable [] getPayload()- Returns:
- the payload of the last will.
-
getQos
public int getQos()- Returns:
- quality of service level.
-
isRetain
public boolean isRetain()- Returns:
- true if the last will should be retained by the broker.
-
toString