IotHubListener Interface

public interface IotHubListener

Callback interface for communicating connection and message status updates from individual protocol clients (mqtt, https, amqps) to the transport layer that handles queueing of messages and connecting/reconnecting/disconnecting

Method Summary

Modifier and Type Method and Description
abstract void onConnectionEstablished(String connectionId)

Callback to be fired when the connection has been successfully established

abstract void onConnectionLost(Throwable e, String connectionId)

Callback to be fired when connection has been lost

abstract void onMessageReceived(IotHubTransportMessage transportMessage, Throwable e)

Callback to be fired when a transport message has been received.

abstract void onMessageSent(Message message, String deviceId, Throwable e)

Callback to be fired when a message that the transport client sent has been acknowledged by Iot Hub

abstract void onMultiplexedDeviceSessionEstablished(String connectionId, String deviceId)

Callback to be fired when the multiplexed connection establishes a new device session.

abstract void onMultiplexedDeviceSessionLost(Throwable e, String connectionId, String deviceId)

Callback to be fired when the multiplexed connection loses a device session.

abstract void onMultiplexedDeviceSessionRegistrationFailed(String connectionId, String deviceId, Exception e)

Callback to be fired when the multiplexed connection fails to register a device session.

Method Details

onConnectionEstablished

public abstract void onConnectionEstablished(String connectionId)

Callback to be fired when the connection has been successfully established

Parameters:

connectionId - the id of the connection this update is relevant to

onConnectionLost

public abstract void onConnectionLost(Throwable e, String connectionId)

Callback to be fired when connection has been lost

Parameters:

e - the cause of the connection loss
connectionId - the id of the connection this update is relevant to

onMessageReceived

public abstract void onMessageReceived(IotHubTransportMessage transportMessage, Throwable e)

Callback to be fired when a transport message has been received.

Parameters:

transportMessage - The message that was received. May be null if e is not null
e - the exception that was encountered while receiving messages. May be null if transportMessage is not null

onMessageSent

public abstract void onMessageSent(Message message, String deviceId, Throwable e)

Callback to be fired when a message that the transport client sent has been acknowledged by Iot Hub

Parameters:

message - The message that was acknowledged
deviceId - The device that the message was sent from
e - Null if the message was successfully acknowledged. Otherwise, this exception communicates if the message should be resent at all

onMultiplexedDeviceSessionEstablished

public abstract void onMultiplexedDeviceSessionEstablished(String connectionId, String deviceId)

Callback to be fired when the multiplexed connection establishes a new device session.

Parameters:

connectionId
deviceId - the Id of the device that the session belongs to

onMultiplexedDeviceSessionLost

public abstract void onMultiplexedDeviceSessionLost(Throwable e, String connectionId, String deviceId)

Callback to be fired when the multiplexed connection loses a device session.

Parameters:

e
connectionId
deviceId - the Id of the device that the session belongs to

onMultiplexedDeviceSessionRegistrationFailed

public abstract void onMultiplexedDeviceSessionRegistrationFailed(String connectionId, String deviceId, Exception e)

Callback to be fired when the multiplexed connection fails to register a device session.

Parameters:

connectionId - the Id of the connection, used to identify which of possible many reconnection attempts this event belongs to.
deviceId - the Id of the device that the session belongs to
e - the throwable that explains why the registration failed.

Applies to