Files
Mosquitto/examples/01_publish.jl
2023-03-14 11:29:44 +07:00

11 lines
397 B
Julia

using Mosquitto, Dates
# connect to a broker, also start loop if Threads.nthreads() > 1
client = Client("test.mosquitto.org")
topic = "test/julia"
message = "Hello World from Julia, send on $(now(UTC)) using the Mosquitto wrapper https://github.com/denglerchr/Mosquitto.jl"
publish(client, topic, message; retain = true)
!client.status.loop_status && loop(client; ntimes = 2)
disconnect(client)