org.eclipse.paho.client.mqttv3.internal.wire
Class MqttPublish

java.lang.Object
  extended by org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage
      extended by org.eclipse.paho.client.mqttv3.internal.wire.MqttPersistableWireMessage
          extended by org.eclipse.paho.client.mqttv3.internal.wire.MqttPublish
All Implemented Interfaces:
MqttPersistable

public class MqttPublish
extends MqttPersistableWireMessage

An on-the-wire representation of an MQTT SEND message.


Field Summary
 
Fields inherited from class org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage
duplicate, MESSAGE_TYPE_CONNACK, MESSAGE_TYPE_CONNECT, MESSAGE_TYPE_DISCONNECT, MESSAGE_TYPE_PINGREQ, MESSAGE_TYPE_PINGRESP, MESSAGE_TYPE_PUBACK, MESSAGE_TYPE_PUBCOMP, MESSAGE_TYPE_PUBLISH, MESSAGE_TYPE_PUBREC, MESSAGE_TYPE_PUBREL, MESSAGE_TYPE_SUBACK, MESSAGE_TYPE_SUBSCRIBE, MESSAGE_TYPE_UNSUBACK, MESSAGE_TYPE_UNSUBSCRIBE, msgId, STRING_ENCODING
 
Constructor Summary
MqttPublish(byte info, byte[] data)
          Constructs a new MqttPublish object.
MqttPublish(String name, MqttMessage message)
           
 
Method Summary
protected static byte[] encodePayload(MqttMessage message)
           
 MqttMessage getMessage()
           
protected  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.
 int getPayloadLength()
          Returns the length of the payload.
 String getTopicName()
           
protected  byte[] getVariableHeader()
           
 boolean isMessageIdRequired()
          Returns whether or not this message needs to include a message ID.
 void setMessageId(int msgId)
          Sets the MQTT message ID.
 String toString()
           
 
Methods inherited from class org.eclipse.paho.client.mqttv3.internal.wire.MqttPersistableWireMessage
getHeaderBytes, getHeaderLength, getHeaderOffset, getPayloadBytes, getPayloadOffset
 
Methods inherited from class org.eclipse.paho.client.mqttv3.internal.wire.MqttWireMessage
createWireMessage, createWireMessage, decodeUTF8, encodeMBI, encodeMessageId, encodeUTF8, getHeader, getKey, getMessageId, getType, isRetryable, readMBI, setDuplicate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MqttPublish

public MqttPublish(String name,
                   MqttMessage message)

MqttPublish

public MqttPublish(byte info,
                   byte[] data)
            throws MqttException,
                   IOException
Constructs a new MqttPublish object.

Parameters:
info - the message info byte
data - the variable header and payload bytes
Throws:
MqttException
IOException
Method Detail

toString

public String toString()
Overrides:
toString in class MqttWireMessage

getMessageInfo

protected byte getMessageInfo()
Description copied from class: MqttWireMessage
Sub-classes should override this to encode the message info. Only the least-significant four bits will be used.

Specified by:
getMessageInfo in class MqttWireMessage

getTopicName

public String getTopicName()

getMessage

public MqttMessage getMessage()

encodePayload

protected static byte[] encodePayload(MqttMessage message)

getPayload

public byte[] getPayload()
                  throws MqttException
Description copied from class: MqttWireMessage
Sub-classes should override this method to supply the payload bytes.

Overrides:
getPayload in class MqttWireMessage
Throws:
MqttException

getPayloadLength

public int getPayloadLength()
Description copied from interface: MqttPersistable
Returns the length of the payload.

Specified by:
getPayloadLength in interface MqttPersistable
Overrides:
getPayloadLength in class MqttPersistableWireMessage
Returns:
the payload length.

setMessageId

public void setMessageId(int msgId)
Description copied from class: MqttWireMessage
Sets the MQTT message ID.

Overrides:
setMessageId in class MqttWireMessage

getVariableHeader

protected byte[] getVariableHeader()
                            throws MqttException
Specified by:
getVariableHeader in class MqttWireMessage
Throws:
MqttException

isMessageIdRequired

public boolean isMessageIdRequired()
Description copied from class: MqttWireMessage
Returns whether or not this message needs to include a message ID.

Overrides:
isMessageIdRequired in class MqttWireMessage


Copyright © 2013. All Rights Reserved.