改用更精确的定时器

This commit is contained in:
洛洛希雅 2024-05-08 13:52:13 +08:00
parent b720bf4b24
commit 37b00d8d17

View File

@ -88,7 +88,12 @@ async function publish() {
}
publishing.startTime = Date.now()
publishing.count = list.length
while (!exit) {
//
const interval = setInterval(() => {
if (exit) {
clearInterval(interval)
return
}
const item = next()
publishing.lastTime = Date.now()
if (item[0]?.content[0]) {
@ -103,9 +108,7 @@ async function publish() {
const json = JSON.stringify(item)
mqttClient!.publish(topic, json, {})
await delay(100)
}
}, 100)
})().catch((e) => console.error(e))
}
</script>