Android Programming Press on the image to return to the main documentation page.

iMQTT

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 MqttConnectOptions)

  Connected As Boolean [read only]

  Initialize (EventName As String, ServerURI As String, ClientId As String)

  IsInitialized As Boolean [read only]

  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 [read only]

  QOS_1_LEAST_ONCE As Int [read only]

  QOS_2_EXACTLY_ONCE As Int [read only]

  Subscribe (Topic As String, QOS As Int)

  Unsubscribe (Topic As String)

Members description:

ClientId As String [read only]
Close
Closes the connection.
Connect
Tries to connect to the broker. The Connected event will be raised.
Connect2 (Options As MqttConnectOptions)
Similar to Connect. Allows you to configure the connection options.
Connected As Boolean [read only]
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
IsInitialized As Boolean [read only]
Publish (Topic As String, Payload() As Byte)
Publishes a message to the given topic. The QOS will be set to 0 (note that it is different than jMQTT default).
Topic - The message will be delivered to this topic.
Payload - Message payload.
For example:
Client.Publish("Topic", "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 [read only]
QOS_1_LEAST_ONCE As Int [read only]
QOS_2_EXACTLY_ONCE As Int [read only]
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)

  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.
Password As String
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

Top