public class Client
extends java.lang.Object
Constructor and Description |
---|
Client() |
Modifier and Type | Method and Description |
---|---|
void |
addTopicListener(java.lang.String topic,
TopicListener listener)
Adds a topic listener on a topic.
|
void |
connect(ConnectOptions connectOptions)
Use the connection options to open a connection to the AWS IoT services.
|
void |
disconnect()
Disconnect this client from the underlying communication layer.
|
boolean |
isConnected()
Returns the state of the connection.
|
void |
publish(java.lang.String topic,
byte[] data)
Publishes a message on a topic.
|
void |
subscribe(java.lang.String topic)
Subscribe to a topic.
|
void |
unsubscribe(java.lang.String topic)
Unsubscribe from a topic.
|
public boolean isConnected()
public void connect(ConnectOptions connectOptions) throws IotCoreException
connectOptions
- the specific AWS IoT optionsIotCoreException
- when already connected or on communication errorspublic void disconnect() throws IotCoreException
IotCoreException
- when not connectedpublic void subscribe(java.lang.String topic) throws IotCoreException
topic
- the topic you want to listened toIotCoreException
- when not connected and when no TopicListener was installedpublic void unsubscribe(java.lang.String topic) throws IotCoreException
topic
- the topic you want to stop listening toIotCoreException
- when not connected or on communication errorpublic void publish(java.lang.String topic, byte[] data) throws IotCoreException
topic
- the topic you want to publish ondata
- the data you want to publishIotCoreException
- when not connected or on communication errorpublic void addTopicListener(java.lang.String topic, TopicListener listener) throws IotCoreException
topic
- the topic to add the listener on, one listener is allowed per
topiclistener
- the TopicListener that will process the received dataIotCoreException
- when not connected or on communication error