|
eWON JTK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ewon.ewonitf.MqttClient
public abstract class MqttClient
Constructor Summary | |
---|---|
MqttClient(String MqttId,
String Host)
Create an MQTT client instance. |
Method Summary | |
---|---|
void |
call(int eventHandler,
String nullStr,
int clientHandle)
Internal use only, this function will be called when an MQTT event occurs. |
abstract void |
callMqttEvent(int event)
This abstract function must be defined in your actual MQTT client. |
void |
close()
Call this function when the client must not be used any more to release all allocated resources. |
void |
connect()
Connect to the selected host with the parameters configured. |
protected void |
finalize()
|
int |
getIntRef()
Internally used for event management. |
void |
publish(MqttMessage msg,
int QoS,
boolean retain)
Call this function to publish a message to the broker. |
MqttMessage |
readMessage()
Read a message from the receive queue. |
void |
setOption(String paramName,
String paramValue)
Configure an option in the client. |
void |
subscribe(String subscriptionPattern,
int QoS)
Subscribe to a topic pattern. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MqttClient(String MqttId, String Host) throws Exception
MqttId
- String used to identify the client in the broker.Host
- The IP address or name of the broker.
Exception
- if creation fails.Method Detail |
---|
public int getIntRef()
getIntRef
in interface EvtIntListener
public void setOption(String paramName, String paramValue) throws EWException
connect()
function to configure the connection.
paramName
- The parameter to configure.
possible values are:
paramValue
- The value to set the parameter.
EWException
public void connect() throws EWException
EWException
public void subscribe(String subscriptionPattern, int QoS) throws EWException
For example, for a topic of "a/b/c/d", the following example subscriptions will match:
- a/b/c/d
- +/b/c/d
- a/+/c/d
- a/+/+/d
- +/+/+/+
The following subscriptions will not match:
- a/b/c
- b/+/c/d
- +/+/+
# can be used as a wildcard for all remaining levels of hierarchy. This means that it must be the final character in a subscription. With a topic of "a/b/c/d", the following example subscriptions will match:
- a/b/c/d
- #
- a/#
- a/b/#
- a/b/c/#
- +/b/c/#
- Parameters:
subscriptionPattern
- The pattern for the subscription.QoS
- The quality of service for the subscription.- Throws:
EWException
public MqttMessage readMessage() throws EWException
null
if no message was available.
EWException
public void close()
public void publish(MqttMessage msg, int QoS, boolean retain) throws EWException
This is an example of how to publish a string to the root/home topic.
myMqttClient.publish(new MqttMessage("root/home","abdc", 0, false);
msg
- The message instance to publish.QoS
- The QoS to be used for publishing the message.retain
- Define if the message must be retained by the broker for future clients that will connect.
EWException
public abstract void callMqttEvent(int event)
msg
is not null.
event
- is reserved for future use. Currently always 0.public void call(int eventHandler, String nullStr, int clientHandle)
call
in interface EvtListener
eventHandler
- nullStr
- clientHandle
- protected void finalize()
|
eWON JTK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |