IotHubTransportPacket Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.transport.IotHubTransportPacket

public class IotHubTransportPacket

A packet containing the data needed for an IoT Hub transport to send a message.

Constructor Summary

Constructor Description
IotHubTransportPacket(Message message, MessageSentCallback eventCallback, Object callbackContext, IotHubStatusCode status, long startTimeMillis, String deviceId)

Constructor.

Method Summary

Modifier and Type Method and Description
MessageSentCallback getCallback()

Getter for the callback to be invoked when a response is received.

Object getContext()

Getter for the context to be passed to the callback when it is invoked.

int getCurrentRetryAttempt()

Getter for current retry attempt. This count should be incremented using incrementRetryAttempt

String getDeviceId()

Get the Id of the device that this packet is being sent from.

Message getMessage()

Getter for the message to be sent.

long getStartTimeMillis()

Getter for startTimeMillis

IotHubStatusCode getStatus()

Get the status of this transport packet

void incrementRetryAttempt()

Increments the saved retry attempt count by 1

void setStatus(IotHubStatusCode status)

Set the status of this transport packet

Constructor Details

IotHubTransportPacket

public IotHubTransportPacket(Message message, MessageSentCallback eventCallback, Object callbackContext, IotHubStatusCode status, long startTimeMillis, String deviceId)

Constructor.

Parameters:

message - the message to be sent.
eventCallback - the callback to be invoked when a response from the IoT Hub is received.
callbackContext - the context to be passed to the callback.
status - the status code associated with the message
startTimeMillis - the milliseconds since epoch that this packet was created. Used for tracking how long a packet has been in process for
deviceId - The Id of the device that this message will be sent by.

Throws:

IllegalArgumentException - if startTimeMillis is 0 or negative

Method Details

getCallback

public MessageSentCallback getCallback()

Getter for the callback to be invoked when a response is received.

Returns:

the eventCallback function. It can benull 

</code> . </p>

getContext

public Object getContext()

Getter for the context to be passed to the callback when it is invoked.

Returns:

the callback context.

getCurrentRetryAttempt

public int getCurrentRetryAttempt()

Getter for current retry attempt. This count should be incremented using incrementRetryAttempt

Returns:

the current retry attempt

getDeviceId

public String getDeviceId()

Get the Id of the device that this packet is being sent from.

Returns:

The Id of the device that this packet is being sent from.

getMessage

public Message getMessage()

Getter for the message to be sent.

Returns:

the message to be sent.

getStartTimeMillis

public long getStartTimeMillis()

Getter for startTimeMillis

Returns:

the number of milliseconds since epoch that this packet was created

getStatus

public IotHubStatusCode getStatus()

Get the status of this transport packet

Returns:

the status of this packet

incrementRetryAttempt

public void incrementRetryAttempt()

Increments the saved retry attempt count by 1

setStatus

public void setStatus(IotHubStatusCode status)

Set the status of this transport packet

Parameters:

status - the status to set for this packet

Applies to