net.sf.xenqtt.message
Class IdentifiableMqttMessage

java.lang.Object
  extended by net.sf.xenqtt.message.MqttMessage
      extended by net.sf.xenqtt.message.IdentifiableMqttMessage
Direct Known Subclasses:
PubAckMessage, PubCompMessage, PubMessage, PubRecMessage, PubRelMessage, SubAckMessage, SubscribeMessage, UnsubAckMessage, UnsubscribeMessage

public abstract class IdentifiableMqttMessage
extends MqttMessage

Adds the message ID property to MqttMessage. Since different messages have this property in different places the implementations are abstract.


Constructor Summary
IdentifiableMqttMessage(ByteBuffer buffer, int remainingLength, long receivedTimestamp)
           
IdentifiableMqttMessage(MessageType messageType, boolean duplicate, QoS qos, boolean retain, int remainingLength)
           
IdentifiableMqttMessage(MessageType messageType, int remainingLength)
           
 
Method Summary
 int getMessageId()
          The message identifier is present in the variable header of the following MQTT messages: PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK.
 void setMessageId(int messageId)
          Sets the message ID
 
Methods inherited from class net.sf.xenqtt.message.MqttMessage
byteBufferToHex, bytesToHex, equals, getMessageType, getQoS, getQoSLevel, getReceivedTimestamp, getRemainingLength, isAck, isAckable, isDuplicate, isRetain, setDuplicateFlag, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdentifiableMqttMessage

public IdentifiableMqttMessage(ByteBuffer buffer,
                               int remainingLength,
                               long receivedTimestamp)
See Also:
MqttMessage#MqttMessage(ByteBuffer, int)

IdentifiableMqttMessage

public IdentifiableMqttMessage(MessageType messageType,
                               int remainingLength)
See Also:
MqttMessage.MqttMessage(MessageType, int)

IdentifiableMqttMessage

public IdentifiableMqttMessage(MessageType messageType,
                               boolean duplicate,
                               QoS qos,
                               boolean retain,
                               int remainingLength)
See Also:
MqttMessage.MqttMessage(MessageType, boolean, QoS, boolean, int)
Method Detail

getMessageId

public int getMessageId()
The message identifier is present in the variable header of the following MQTT messages: PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK.

The Message Identifier (Message ID) field is only present in messages where the QoS bits in the fixed header indicate QoS levels 1 or 2. See section on Quality of Service levels and flows for more information.

The Message ID is a 16-bit unsigned integer that must be unique amongst the set of "in flight" messages in a particular direction of communication. It typically increases by exactly one from one message to the next, but is not required to do so.

A client will maintain its own list of Message IDs separate to the Message IDs used by the server it is connected to. It is possible for a client to send a PUBLISH with Message ID 1 at the same time as receiving a PUBLISH with Message ID 1.

Do not use Message ID 0. It is reserved as an invalid Message ID.

Override this implementation for messages where the message ID is not at offset 2 of a fixed length message


setMessageId

public void setMessageId(int messageId)
Sets the message ID

Override this implementation for messages where the message ID is not at offset 2 of a fixed length message



Copyright © 2013. All Rights Reserved.