|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage
public abstract class MqttWireMessage
An on-the-wire representation of an MQTT message.
Field Summary | |
---|---|
protected boolean |
duplicate
|
static byte |
MESSAGE_TYPE_CONNACK
|
static byte |
MESSAGE_TYPE_CONNECT
|
static byte |
MESSAGE_TYPE_DISCONNECT
|
static byte |
MESSAGE_TYPE_PINGREQ
|
static byte |
MESSAGE_TYPE_PINGRESP
|
static byte |
MESSAGE_TYPE_PUBACK
|
static byte |
MESSAGE_TYPE_PUBCOMP
|
static byte |
MESSAGE_TYPE_PUBLISH
|
static byte |
MESSAGE_TYPE_PUBREC
|
static byte |
MESSAGE_TYPE_PUBREL
|
static byte |
MESSAGE_TYPE_SUBACK
|
static byte |
MESSAGE_TYPE_SUBSCRIBE
|
static byte |
MESSAGE_TYPE_UNSUBACK
|
static byte |
MESSAGE_TYPE_UNSUBSCRIBE
|
protected int |
msgId
The MQTT message ID |
protected static String |
STRING_ENCODING
|
Constructor Summary | |
---|---|
MqttWireMessage(byte type)
|
Method Summary | |
---|---|
static MqttWireMessage |
createWireMessage(byte[] bytes)
|
static MqttWireMessage |
createWireMessage(MqttPersistable data)
|
protected String |
decodeUTF8(DataInputStream input)
Decodes a UTF-8 string from the DataInputStream provided. |
protected static byte[] |
encodeMBI(long number)
|
protected byte[] |
encodeMessageId()
|
protected void |
encodeUTF8(DataOutputStream dos,
String stringToEncode)
Encodes a String given into UTF-8, before writing this to the DataOutputStream the length of the encoded string is encoded into two bytes and then written to the DataOutputStream. |
byte[] |
getHeader()
|
String |
getKey()
Returns a key associated with the message. |
int |
getMessageId()
Returns the MQTT message ID. |
protected abstract byte |
getMessageInfo()
Sub-classes should override this to encode the message info. |
byte[] |
getPayload()
Sub-classes should override this method to supply the payload bytes. |
byte |
getType()
Returns the type of the message. |
protected abstract byte[] |
getVariableHeader()
|
boolean |
isMessageIdRequired()
Returns whether or not this message needs to include a message ID. |
boolean |
isRetryable()
|
protected static MultiByteInteger |
readMBI(DataInputStream in)
Decodes an MQTT Multi-Byte Integer from the given stream. |
void |
setDuplicate(boolean duplicate)
|
void |
setMessageId(int msgId)
Sets the MQTT message ID. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final String STRING_ENCODING
public static final byte MESSAGE_TYPE_CONNECT
public static final byte MESSAGE_TYPE_CONNACK
public static final byte MESSAGE_TYPE_PUBLISH
public static final byte MESSAGE_TYPE_PUBACK
public static final byte MESSAGE_TYPE_PUBREC
public static final byte MESSAGE_TYPE_PUBREL
public static final byte MESSAGE_TYPE_PUBCOMP
public static final byte MESSAGE_TYPE_SUBSCRIBE
public static final byte MESSAGE_TYPE_SUBACK
public static final byte MESSAGE_TYPE_UNSUBSCRIBE
public static final byte MESSAGE_TYPE_UNSUBACK
public static final byte MESSAGE_TYPE_PINGREQ
public static final byte MESSAGE_TYPE_PINGRESP
public static final byte MESSAGE_TYPE_DISCONNECT
protected int msgId
protected boolean duplicate
Constructor Detail |
---|
public MqttWireMessage(byte type)
Method Detail |
---|
protected abstract byte getMessageInfo()
public byte[] getPayload() throws MqttException
MqttException
public byte getType()
public int getMessageId()
public void setMessageId(int msgId)
public String getKey()
public byte[] getHeader() throws MqttException
MqttException
protected abstract byte[] getVariableHeader() throws MqttException
MqttException
public boolean isMessageIdRequired()
public static MqttWireMessage createWireMessage(MqttPersistable data) throws MqttException
MqttException
public static MqttWireMessage createWireMessage(byte[] bytes) throws MqttException
MqttException
protected static byte[] encodeMBI(long number)
protected static MultiByteInteger readMBI(DataInputStream in) throws IOException
IOException
protected byte[] encodeMessageId() throws MqttException
MqttException
public boolean isRetryable()
public void setDuplicate(boolean duplicate)
protected void encodeUTF8(DataOutputStream dos, String stringToEncode) throws MqttException
dos
- The stream to write the encoded UTF-8 String to.stringToEncode
- The String to be encoded
MqttException
- Thrown when an error occurs with either the encoding or writing the data to the streamprotected String decodeUTF8(DataInputStream input) throws MqttException
input
- The input stream from which to read the encoded string
MqttException
- thrown when an error occurs with either reading from the stream or
decoding the encoded string.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |