Press on the image to return to the main documentation page.
jMQTT
List of types:
MqttClient
MqttConnectOptions
MqttClient
Implementation of a MQTT client.
Events:
Connected (Success As Boolean)
Disconnected
MessageArrived (Topic As String, Payload() As Byte)
Members:
ClientId
As
String
[read
only]
Close
Connect
Connect2
(
Options
As
org
.
eclipse
.
paho
.
client
.
mqttv3
.
MqttConnectOptions
)
Connected
As
Boolean
[read
only]
Initialize
(
EventName
As
String
,
ServerURI
As
String
,
ClientId
As
String
)
IsInitialized
As
Boolean
Publish
(
Topic
As
String
,
Payload
()
As
Byte
)
Publish2
(
Topic
As
String
,
Payload
()
As
Byte
,
QOS
As
Int
,
Retained
As
Boolean
)
QOS_0_MOST_ONCE
As
Int
QOS_1_LEAST_ONCE
As
Int
QOS_2_EXACTLY_ONCE
As
Int
Subscribe
(
Topic
As
String
,
QOS
As
Int
)
Unsubscribe
(
Topic
As
String
)
Members description:
ClientId
As
String
[read
only]
Gets the client id.
Close
Asynchronously closes the connection.
Connect
Tries to connect to the broker. The Connected event will be raised.
Connect2
(
Options
As
org
.
eclipse
.
paho
.
client
.
mqttv3
.
MqttConnectOptions
)
Similar to Connect. Allows you to configure the connection options.
Connected
As
Boolean
[read
only]
Returns true if the client is connected.
Initialize
(
EventName
As
String
,
ServerURI
As
String
,
ClientId
As
String
)
Initializes the client.
EventName - Sets the subs that will handle the events.
ServerURI - The server URI. For example: tcp://localhost:51044 or ssl://localhost:51044
ClientId - Client ID (each client needs a unique id).
IsInitialized
As
Boolean
Publish
(
Topic
As
String
,
Payload
()
As
Byte
)
Publishes a message to the given topic. The QOS will be set to 1.
Topic - The message will be delivered to this topic.
Payload - Message payload.
For example:
Client
.
Publish
(
"Topic1"
,
"Message"
.
GetBytes
(
"UTF8"
))
Publish2
(
Topic
As
String
,
Payload
()
As
Byte
,
QOS
As
Int
,
Retained
As
Boolean
)
Publishes a message to the given topic.
Topic - The message will be delivered to this topic.
Payload - Message payload.
QOS - The QOS level.
Retained - Whether the server should retain the message (only the last message per topic is retained).
QOS_0_MOST_ONCE
As
Int
QOS_1_LEAST_ONCE
As
Int
QOS_2_EXACTLY_ONCE
As
Int
Subscribe
(
Topic
As
String
,
QOS
As
Int
)
Subscribes to the given topic.
Topic - Topic to subscribe.
QOS - QOS setting.
Unsubscribe
(
Topic
As
String
)
Unsubscribes from the given topic.
MqttConnectOptions
Events:
None
Members:
CleanSession
As
Boolean
Initialize
(
UserName
As
String
,
Password
As
String
)
IsInitialized
As
Boolean
Password
As
String
SetLastWill
(
Topic
As
String
,
Payload
()
As
Byte
,
QOS
As
Int
,
Retained
As
Boolean
)
UserName
As
String
Members description:
CleanSession
As
Boolean
If set to true (default value) then the state will not be preserved in the case of client restarts.
Initialize
(
UserName
As
String
,
Password
As
String
)
Initializes the object and sets the username and password.
Pass empty strings if username or password are not required.
IsInitialized
As
Boolean
Password
As
String
Gets or sets the connection password.
SetLastWill
(
Topic
As
String
,
Payload
()
As
Byte
,
QOS
As
Int
,
Retained
As
Boolean
)
Sets the Last Will message that will be sent if the client was disconnected abruptly.
UserName
As
String
Gets or sets the connection user name.
Top