com.esf.net.mqtt.client.service
Interface IEsfMqttMasterClient


public interface IEsfMqttMasterClient


Method Summary
 boolean isConnected()
          Returns an indication of whether the MQtt connection to the broker is established.
 int publish(java.lang.String topic, byte[] payload, int qos)
          Publishes a message to the MQtt broker.
 int publish(java.lang.String sensorId, java.lang.String topic, byte[] payload, int qos)
          Publishes a message to the MQtt broker.
 void registerCallback(IEsfMqttCallback handler)
          Register an IEsfMqttCallback with the IEsfMqttClient.
 int subscribe(EsfMqttSubscription subscription)
          Subscribes to a topic with the MQtt broker.
 int subscribe(EsfMqttSubscription[] subscriptions)
          Subscribes to one or more topics with the MQtt broker.
 int subscribe(java.lang.String sensorId, EsfMqttSubscription subscription)
          Subscribes to a topic with the MQtt broker.
 int subscribe(java.lang.String sensorId, EsfMqttSubscription[] subscriptions)
          Subscribes to one or more topics with the MQtt broker.
 int subscribe(java.lang.String topic, int qos)
          Subscribes to a topic with the MQtt broker.
 int subscribe(java.lang.String sensorId, java.lang.String topic, int qos)
          Subscribes to a topic with the MQtt broker.
 int unsubscribe(EsfMqttSubscription subscription)
          Unsubscribes from a topic with the MQtt broker.
 int unsubscribe(java.lang.String topic)
          Unsubscribes from a topic with the MQtt broker.
 int unsubscribe(java.lang.String sensorId, EsfMqttSubscription subscription)
          Unsubscribes from a topic with the MQtt broker.
 int unsubscribe(java.lang.String sensorId, java.lang.String topic)
          Unsubscribes from a topic with the MQtt broker.
 

Method Detail

publish

int publish(java.lang.String topic,
            byte[] payload,
            int qos)
            throws EsfMqttException
Publishes a message to the MQtt broker.

Parameters:
topic - A String specifying the topic the message was published on.
payload - An array of bytes containing the payload of the message.
qos - An integer specifying the quality of service the message was published on.
Returns:
The published message's ID.
Throws:
EsfMqttException

publish

int publish(java.lang.String sensorId,
            java.lang.String topic,
            byte[] payload,
            int qos)
            throws EsfMqttException
Publishes a message to the MQtt broker.

Parameters:
sensorId - A String specifying the sensor ID.
topic - A String specifying the topic the message was published on.
payload - An array of bytes containing the payload of the message.
qos - An integer specifying the quality of service the message was published on.
Returns:
The published message's ID.
Throws:
EsfMqttException

subscribe

int subscribe(java.lang.String sensorId,
              EsfMqttSubscription[] subscriptions)
              throws EsfMqttException
Subscribes to one or more topics with the MQtt broker. The topics are specified as an array of EsfMqttSubscription objects. If the subscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
sensorId - A String specifying the sensor ID.
subscriptions - An array of EsfMqttSubscription objects.
Returns:
The subscribe message's ID.
Throws:
EsfMqttException

subscribe

int subscribe(java.lang.String sensorId,
              EsfMqttSubscription subscription)
              throws EsfMqttException
Subscribes to a topic with the MQtt broker. The topic and QoS are specified in an EsfMqttSubscription object. If the subscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
sensorId - A String specifying the sensor ID.
subscription - An EsfMqttSubscription object.
Returns:
The subscribe message's ID.
Throws:
EsfMqttException

subscribe

int subscribe(java.lang.String sensorId,
              java.lang.String topic,
              int qos)
              throws EsfMqttException
Subscribes to a topic with the MQtt broker. The topic is specified as a String object and the QoS is specified as an interger. If the subscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
sensorId - A String specifying the sensor ID.
topic - A String object containing the topic.
qos - An int containing the Quality of Service.
Returns:
The subscribe message's ID.
Throws:
EsfMqttException

unsubscribe

int unsubscribe(java.lang.String sensorId,
                EsfMqttSubscription subscription)
                throws EsfMqttException
Unsubscribes from a topic with the MQtt broker. An EsfMqttSubscription topic is specified that contains the topic in which to unsubscribe from. If the unsubscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
sensorId - A String specifying the sensor ID.
subscription - A EsfMqttSubscription object containing the topic.
Returns:
The unsubscribe message's ID.
Throws:
EsfMqttException

unsubscribe

int unsubscribe(java.lang.String sensorId,
                java.lang.String topic)
                throws EsfMqttException
Unsubscribes from a topic with the MQtt broker. A String object is specified which contains the topic in which to unsubscribe from. If the unsubscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
sensorId - A String specifying the sensor ID.
topic - A String object containing the topic.
Returns:
The unsubscribe message's ID.
Throws:
EsfMqttException

unsubscribe

int unsubscribe(EsfMqttSubscription subscription)
                throws EsfMqttException
Unsubscribes from a topic with the MQtt broker. An EsfMqttSubscription topic is specified that contains the topic in which to unsubscribe from. If the unsubscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
subscription - A EsfMqttSubscription object containing the topic.
Returns:
The unsubscribe message's ID.
Throws:
EsfMqttException

unsubscribe

int unsubscribe(java.lang.String topic)
                throws EsfMqttException
Unsubscribes from a topic with the MQtt broker. A String object is specified which contains the topic in which to unsubscribe from. If the unsubscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
topic - A String object containing the topic.
Returns:
The unsubscribe message's ID.
Throws:
EsfMqttException

subscribe

int subscribe(EsfMqttSubscription[] subscriptions)
              throws EsfMqttException
Subscribes to one or more topics with the MQtt broker. The topics are specified as an array of EsfMqttSubscription objects. If the subscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
subscriptions - An array of EsfMqttSubscription objects.
Returns:
The subscribe message's ID.
Throws:
EsfMqttException

subscribe

int subscribe(EsfMqttSubscription subscription)
              throws EsfMqttException
Subscribes to a topic with the MQtt broker. The topic and QoS are specified in an EsfMqttSubscription object. If the subscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
subscription - An EsfMqttSubscription object.
Returns:
The subscribe message's ID.
Throws:
EsfMqttException

subscribe

int subscribe(java.lang.String topic,
              int qos)
              throws EsfMqttException
Subscribes to a topic with the MQtt broker. The topic is specified as a String object and the QoS is specified as an interger. If the subscribe fails, an exception will be thrown that will contain information about the cause of the failure.

Parameters:
topic - A String object containing the topic.
qos - An int containing the Quality of Service.
Returns:
The subscribe message's ID.
Throws:
EsfMqttException

isConnected

boolean isConnected()
Returns an indication of whether the MQtt connection to the broker is established.

Returns:
boolean, whether connection to broker is established.

registerCallback

void registerCallback(IEsfMqttCallback handler)
Register an IEsfMqttCallback with the IEsfMqttClient. This handler will receive events when a client publication has arrived, and when a publish (QoS > 0) has been fully acknowledged by the broker.

Parameters:
handler - An implementation of the IEsfMqttCallback interface.