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

rMQTT

List of types:

MqttClient
MqttConnectOptions

MqttClient


Events:

MessageArrived (Topic As String, Payload() As Byte)
Disconnected

Members:


  Close As void

  Connect As Boolean

  Connect2 (Options As MqttConnectOptions) As Boolean

  Initialize (Stream As B4RStream, Ip() As Byte, Port As UInt, ClientId As String, MessageArrivedSub As SubVoidStringByteArray, DisconnectedSub As SubVoidVoid) As void

  Initialize2 (Stream As B4RStream, HostName As String, Port As UInt, ClientId As String, MessageArrivedSub As SubVoidStringByteArray, DisconnectedSub As SubVoidVoid) As void

  Publish (Topic As String, Payload() As Byte) As Boolean

  Publish2 (Topic As String, Payload() As Byte, Retained As Boolean) As Boolean

  Subscribe (Topic As String, QOS As Byte) As Boolean

  Unsubscribe (Topic As String) As Boolean

Members description:

Close As void
Closes the client.
Connect As Boolean
Tries to connect to the server. Returns true if connection was successful.
Connect2 (Options As MqttConnectOptions) As Boolean
Similar to Connect. Allows passing connection options with a MqttConnectOptions object.
Initialize (Stream As B4RStream, Ip() As Byte, Port As UInt, ClientId As String, MessageArrivedSub As SubVoidStringByteArray, DisconnectedSub As SubVoidVoid) As void
Initializes the client.
Stream - A stream from the network client object. Note that the stream should not be connected before this method.
Ip - Server ip address.
Port - Server port.
ClientId - The client id. Note that the string must be a string literal or a process global string.
MessageArrivedSub - The sub that will handle the MessageArrived event.
DisconnectedSub - The sub that will handle the Disconnected event.
Initialize2 (Stream As B4RStream, HostName As String, Port As UInt, ClientId As String, MessageArrivedSub As SubVoidStringByteArray, DisconnectedSub As SubVoidVoid) As void
Similar to Initialize. Accepts the server host name instead of the ip address.
Publish (Topic As String, Payload() As Byte) As Boolean
Publishes a message to the given topic. The QOS is set to 0.
Publish2 (Topic As String, Payload() As Byte, Retained As Boolean) As Boolean
Similar to Publish. Allows setting the retain flag.
Subscribe (Topic As String, QOS As Byte) As Boolean
Subscribes to the given topic. QOS should be 0 or 1. Returns true if operation was successful.
Unsubscribe (Topic As String) As Boolean
Unsubscribes from the given topic. Returns true if operation was successful.

MqttConnectOptions


Events:

None

Members:


  Initialize (UserName As String, Password As String) As void

  Password As String

  SetLastWill (Topic As String, Message As String, QOS As Byte, Retained As Boolean) As void

  UserName As String

Members description:

Initialize (UserName As String, Password As String) As void
Sets the user name and password. Pass empty strings to omit a value.
Password As String
SetLastWill (Topic As String, Message As String, QOS As Byte, Retained As Boolean) As void
Sets the last will message. This message will be sent if the client is disconnected abruptly.
UserName As String

Top