public class Client extends 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(String topic,
byte[] data) |
void |
setJwt(char[] jwt)
Sets the JSON Web Token to be used for connection.
|
void |
setTopicListener(TopicListener listener) |
void |
subscribe(String topic) |
void |
unsubscribe(String topic) |
public void connect(ConnectOptions connectOptions) throws IotCoreException
connectOptions
- the specific Google Cloud IoT Core optionsIotCoreException
- when already connected and on communication errorspublic void disconnect() throws IotCoreException
IotCoreException
- when not connectedpublic char[] getJwt()
public boolean isConnected()
public void publish(String topic, byte[] data) throws IotCoreException
topic
- the topic you want to publish ondata
- the data you want to publishIotCoreException
- when not connectedpublic void setJwt(char[] jwt)
jwt
- the jwt to used for connection.public void setTopicListener(TopicListener listener)
listener
- the TopicListener that will process the received datapublic void subscribe(String topic) throws IotCoreException
topic
- the topic you want to listened toIotCoreException
- when not connected and when no TopicListener was installedpublic void unsubscribe(String topic) throws IotCoreException
topic
- the topic you want to stop listening toIotCoreException
- when not connected