|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.paho.client.mqttv3.MqttMessage
public class MqttMessage
An MQTT message holds the application payload and options specifying how the message is to be delivered The message includes a "payload" (the body of the message) represented as a byte[].
Constructor Summary | |
---|---|
MqttMessage()
Constructs a message with an empty payload, and all other values set to defaults. |
|
MqttMessage(byte[] payload)
Constructs a message with the specified byte array as a payload, and all other values set to defaults. |
Method Summary | |
---|---|
protected void |
checkMutable()
|
void |
clearPayload()
Clears the payload, resetting it to be empty. |
byte[] |
getPayload()
Returns the payload as a byte array. |
int |
getQos()
Returns the quality of service for this message. |
boolean |
isDuplicate()
Returns whether or not this message might be a duplicate of one which has already been received. |
boolean |
isRetained()
Returns whether or not this message should be/was retained by the server. |
protected void |
setDuplicate(boolean dup)
|
protected void |
setMutable(boolean mutable)
Sets the mutability of this object (whether or not its values can be changed. |
void |
setPayload(byte[] payload)
Sets the payload of this message to be the specified byte array. |
void |
setQos(int qos)
Sets the quality of service for this message. |
void |
setRetained(boolean retained)
Whether or not the publish message should be retained by the messaging engine. |
String |
toString()
Returns a string representation of this message's payload. |
static void |
validateQos(int qos)
Utility method to validate the supplied QoS value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MqttMessage()
public MqttMessage(byte[] payload)
Method Detail |
---|
public static void validateQos(int qos)
IllegalArgumentException
- if value of QoS is not 0, 1 or 2.public byte[] getPayload()
public void clearPayload()
IllegalStateException
- if this message cannot be editedpublic void setPayload(byte[] payload)
payload
- the payload for this message.
IllegalStateException
- if this message cannot be edited
NullPointerException
- if no payload is providedpublic boolean isRetained()
true
if the message should be, or was, retained by
the server.setRetained(boolean)
public void setRetained(boolean retained)
false
will clear the
retained message from the server. The default value is false
retained
- whether or not the messaging engine should retain the message.
IllegalStateException
- if this message cannot be editedpublic int getQos()
setQos(int)
public void setQos(int qos)
MqttCallback.deliveryComplete(IMqttDeliveryToken)
.
Also known as "fire and forget".MqttConnectOptions
.
If a persistence mechanism is not specified, the message will not be
delivered in the event of a client failure.
The message will be acknowledged across the network.
This is the default QoS.MqttConnectOptions
.
If a persistence mechanism is not specified, the message will not be
delivered in the event of a client failure.
qos
- the "quality of service" to use. Set to 0, 1, 2.
IllegalArgumentException
- if value of QoS is not 0, 1 or 2.
IllegalStateException
- if this message cannot be editedpublic String toString()
toString
in class Object
protected void setMutable(boolean mutable)
mutable
- true
if the values can be changed,
false
to prevent them from being changed.protected void checkMutable() throws IllegalStateException
IllegalStateException
protected void setDuplicate(boolean dup)
public boolean isDuplicate()
true
if the message might be a duplicate.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |