This commit is contained in:
2025-03-12 14:09:13 +07:00
parent 512fa4fd9d
commit a35cb48bef

View File

@@ -156,6 +156,7 @@ function mqttClientInstance_v2(
keepaliveCheckInterval::Integer=30,
qos::MQTTClient.QOS=QOS_1,
multiMsg::String="single",
clearOldMsg::Bool=true,
)
client, connection = MQTTClient.MakeConnection(mqttBrokerAddress, mqttBrokerPort)
@@ -182,6 +183,15 @@ function mqttClientInstance_v2(
nothing, # store latest message to prevent doing the same massage twice
)
if clearOldMsg
chnames = keys(msgReceiveChannel)
for i in chnames
while isready(msgReceiveChannel[i])
_ = take!(msgReceiveChannel[i])
end
end
end
return instance
end