|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CloudClient
The CloudClient is designed to be used by single application bundles.
CloudClient instances are acquired from the CloudService and they
are released when the work is completed. Generally, a CloudClient
is acquired during the activation phase of a bundle and it is released
during the deactivation phase.
CloudClient leverages the DataService
for all interactions with the transport layer and the communication
with the remote server. CloudClient establishes a set of default
subscriptions that allow remote servers or other devices to direct messages
to the application instance.
If the bundle using the CloudClient relies on custom subscriptions
beyond the default ones, it is responsibility of the application to implement
the CloudClientListener#connectionRestored callback method in the
CloudCallbackHandler to restore the subscriptions it needs.
The CloudClient.release method will unsubscribe all subscriptions
incurred by this client and it will unregister this CloudClient
instance from the list of CloudCallbackHandlers registered.
There can be more than one instance of CloudClient in the system,
ideally one per ApplicationId but this is not enforced.
The class accepts more than one callback handler; all registered handlers are invoked
when a message is received. It is up to the received to analyze the topic
of the message received and handle it appropriately.
The CloudClient publishes and receives messages using a topic namespace
following a structure as: [CRTL_PREFIX/]accountName/deviceId/appId/appTopic.
| Method Summary | |
|---|---|
void |
addCloudClientListener(CloudClientListener cloudClientListener)
Adds a CloudCallbackHandler with this CloudClient. |
int |
controlPublish(String appTopic,
EsfPayload payload,
int qos,
boolean retain,
int priority)
Publishes a control message to the remote server. |
int |
controlPublish(String deviceId,
String appTopic,
byte[] payload,
int qos,
boolean retain,
int priority)
Publishes a control message to the remote server addressing it to another device with a raw byte array payload. |
int |
controlPublish(String deviceId,
String appTopic,
EsfPayload payload,
int qos,
boolean retain,
int priority)
Publishes a control message to the remote server addressing it to another device. |
void |
controlSubscribe(String appTopic,
int qos)
Subscribes to a control topic with the remote server. |
void |
controlUnsubscribe(String appTopic)
Unsubscribes to a control topic with the remote server. |
String |
getApplicationId()
Returns the applicationId of this CloudClient |
List<Integer> |
getDroppedInFlightMessageIds()
Finds the list of identifiers of in-flight messages that have been dropped. |
List<Integer> |
getInFlightMessageIds()
Finds the list of identifiers of messages that are still in-flight (messages published but not confirmed yet). |
List<Integer> |
getUnpublishedMessageIds()
Gets the list of identifiers of messages that have not been published yet. |
boolean |
isConnected()
Returns an indication of whether the connection to the remote server is established. |
int |
publish(String appTopic,
byte[] payload,
int qos,
boolean retain,
int priority)
Publishes a message to the remote server with a raw byte array payload. |
int |
publish(String appTopic,
EsfPayload payload,
int qos,
boolean retain)
Publishes a message to the remote server using the default priority 5. |
int |
publish(String appTopic,
EsfPayload payload,
int qos,
boolean retain,
int priority)
Publishes a message to the remote server. |
void |
release()
Releases this CloudClient handle. |
void |
removeCloudClientListener(CloudClientListener cloudClientListener)
Removes a CloudCallbackHandler from this CloudClient. |
void |
subscribe(String appTopic,
int qos)
Subscribes to a topic with the remote server. |
void |
unsubscribe(String appTopic)
Unubscribes to a topic with the remote server. |
| Method Detail |
|---|
String getApplicationId()
void release()
boolean isConnected()
DataService.connect() and DataService.disconnect(long) methods.
int publish(String appTopic,
EsfPayload payload,
int qos,
boolean retain)
throws EsfException
DataService,
the CloudClient will manipulate the provided topic by appending the necessary parts
to achieve topic partitioning and device identification. It is also responsible to
encode the EsfPayload payload into binary format.
appTopic - A String specifying the application portion of the topic the message is published on.payload - An EsfPayload representing the message to be publishedqos - An integer specifying the quality of service the message was published on.retain - Whether or not the broker should retain the message
EsfException
int publish(String appTopic,
EsfPayload payload,
int qos,
boolean retain,
int priority)
throws EsfException
DataService,
the CloudClient will manipulate the provided topic by appending the necessary parts
to achieve topic partitioning and device identification. It is also responsible to
encode the EsfPayload payload into binary format.
appTopic - A String specifying the application portion of the topic the message is published on.payload - An EsfPayload representing the message to be publishedqos - An integer specifying the quality of service the message was published on.retain - Whether or not the broker should retain the messagepriority - Relative ordering of this message with other messages that may be currently queued for publishing.
EsfException
int publish(String appTopic,
byte[] payload,
int qos,
boolean retain,
int priority)
throws EsfException
DataService,
the CloudClient will manipulate the provided topic by appending the necessary parts
to achieve topic partitioning and device identification.
appTopic - A String specifying the application portion of the topic the message is published on.payload - Binary payload representing the message to be publishedqos - An integer specifying the quality of service the message was published on.retain - Whether or not the broker should retain the messagepriority - Relative ordering of this message with other messages that may be currently queued for publishing.
EsfException
int controlPublish(String appTopic,
EsfPayload payload,
int qos,
boolean retain,
int priority)
throws EsfException
CloudService and it appended
automatically by this controlPublish method. Just as publish(java.lang.String, com.eurotech.framework.message.EsfPayload, int, boolean), the
controlPublish method will manipulate the provided topic by appending the necessary parts
to achieve topic partitioning including device identification and encode
the EsfPayload payload into binary format.
appTopic - A String specifying the application topic the message is published on.payload - An EsfPayload representing the message to be publishedqos - An integer specifying the quality of service the message was published on.retain - Whether or not the broker should retain the messagepriority - Relative ordering of this message with other messages that may be currently queued for publishing.
EsfException
int controlPublish(String deviceId,
String appTopic,
EsfPayload payload,
int qos,
boolean retain,
int priority)
throws EsfException
CloudService and it appended
automatically by this controlPublish method. Just as publish(java.lang.String, com.eurotech.framework.message.EsfPayload, int, boolean), the
controlPublish method will manipulate the provided topic by appending the necessary parts
to achieve topic partitioning including device identification and encode
the EsfPayload payload into binary format.
deviceId - A String specifying the asset ID.appTopic - A String specifying the application topic the message is published on.payload - An EsfPayload representing the message to be publishedqos - An integer specifying the quality of service the message was published on.retain - Whether or not the broker should retain the messagepriority - Relative ordering of this message with other messages that may be currently queued for publishing.
EsfException
int controlPublish(String deviceId,
String appTopic,
byte[] payload,
int qos,
boolean retain,
int priority)
throws EsfException
CloudService and it appended
automatically by this controlPublish method. Just as publish(java.lang.String, com.eurotech.framework.message.EsfPayload, int, boolean), the
controlPublish method will manipulate the provided topic by appending the necessary parts
to achieve topic partitioning including device identification.
deviceId - A String specifying the asset ID.appTopic - A String specifying the application topic the message is published on.payload - Binary payload representing the message to be publishedqos - An integer specifying the quality of service the message was published on.retain - Whether or not the broker should retain the messagepriority - Relative ordering of this message with other messages that may be currently queued for publishing.
EsfException
void subscribe(String appTopic,
int qos)
throws EsfException
appTopic - A String object containing the application topic.qos - An int containing the Quality of Service.
EsfException
void controlSubscribe(String appTopic,
int qos)
throws EsfException
appTopic - A String object containing the application topic.qos - An int containing the Quality of Service.
EsfException
void unsubscribe(String appTopic)
throws EsfException
appTopic - A String object containing the application topic.
EsfException
void controlUnsubscribe(String appTopic)
throws EsfException
appTopic - A String object containing the application topic.
EsfExceptionvoid addCloudClientListener(CloudClientListener cloudClientListener)
cloudCallbackHandler - An implementation of the CloudCallbackHandler interface.void removeCloudClientListener(CloudClientListener cloudClientListener)
List<Integer> getUnpublishedMessageIds()
throws EsfException
EsfException
List<Integer> getInFlightMessageIds()
throws EsfException
EsfException
List<Integer> getDroppedInFlightMessageIds()
throws EsfException
EsfException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||