public class Client
extends java.lang.Object
Constructor and Description |
---|
Client() |
Modifier and Type | Method and Description |
---|---|
void |
connect(ConnectOptions connectOptions)
Use the connection options to open a connection the Google Cloud IoT Core services.
|
void |
disconnect()
Disconnect this client from the underlying communication layer.
|
char[] |
getJwt()
Gets the JSON Web Token once connected.
|
boolean |
isConnected() |
void |
publish(java.lang.String topic,
byte[] data) |
void |
setJwt(char[] jwt)
Sets the JSON Web Token to be used for connection.
|
void |
setTopicListener(TopicListener listener) |
void |
subscribe(java.lang.String topic) |
void |
unsubscribe(java.lang.String topic) |
public boolean isConnected()
public void connect(ConnectOptions connectOptions) throws IotCoreException
connectOptions
- the specific Google Cloud IoT Core optionsIotCoreException
- when already connected and on communication errorspublic char[] getJwt()
public void setJwt(char[] jwt)
jwt
- the jwt to used for connection.public 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 connectedpublic 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 connectedpublic void setTopicListener(TopicListener listener)
listener
- the TopicListener that will process the received data