MQTTClient.resolveFunction
resolve(future)

Fetch the result of a Future object and return it. If the result is an exception, throw the exception, otherwise return the result.

Arguments

  • future: The Future object to fetch the result from.

Returns

  • The result of the Future, or throws an exception if the result is an exception.
source
MQTTClient.topic_eqFunction
topic_eq(baseT::String, compareT::String)

A function that compares two MQTT topics and returns a boolean value based on their equality. If the baseT topic contains a wildcard character #, the macro checks if the compareT topic contains the string before the wildcard character. Otherwise, it checks if the two topics are equal.

Examples

julia> topic_eq("sport/#", "sport/tennis")
true

julia> topic_eq("sport/tennis", "sport/football")
false
source
MQTTClient.MockMQTTBrokerFunction
MockMQTTBroker(args...)
MockMQTTBroker(path::String)
MockMQTTBroker(ip::Sockets.IPAddr, port::Int)

creates a mock mqtt broker over UDS or TCP that handles CONNECT, SUBSCRIBE, UNSUBSCRIBE, PUBLISH, PING, and DISCONNECT messages.

Example

using Sockets # need sockets to us ip""

server = MQTTClient.MockMQTTBroker(ip"127.0.0.1", 1883)
# Sockets.TCPServer(RawFD(20) active)
client, conn = MakeConnection(ip"127.0.0.1", 1883)
# MQTTClient.Configuration(MQTTClient[state: ready, read_loop: ready, write_loop: ready, keep_alive: ready]
# , Connection(Protocol: MQTTClient.TCP(ip"127.0.0.1", 1883), Client ID: OL5hUGmT))

connect(client, conn)
# 0x00

subscribe(client, "foo/bar", (args...) -> nothing)
# 2-element Vector{UInt8}:
#  0x01
#  0x00
publish(client, "bar/foo"; qos=QOS_2)
unsubscribe(client, "foo/bar")

disconnect(client)
# (0x00, 0x00, 0x00)
close(server)
source