改用更精确的定时器
This commit is contained in:
parent
b720bf4b24
commit
37b00d8d17
|
@ -88,7 +88,12 @@ async function publish() {
|
||||||
}
|
}
|
||||||
publishing.startTime = Date.now()
|
publishing.startTime = Date.now()
|
||||||
publishing.count = list.length
|
publishing.count = list.length
|
||||||
while (!exit) {
|
// 发送数据的定时器
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
if (exit) {
|
||||||
|
clearInterval(interval)
|
||||||
|
return
|
||||||
|
}
|
||||||
const item = next()
|
const item = next()
|
||||||
publishing.lastTime = Date.now()
|
publishing.lastTime = Date.now()
|
||||||
if (item[0]?.content[0]) {
|
if (item[0]?.content[0]) {
|
||||||
|
@ -103,9 +108,7 @@ async function publish() {
|
||||||
|
|
||||||
const json = JSON.stringify(item)
|
const json = JSON.stringify(item)
|
||||||
mqttClient!.publish(topic, json, {})
|
mqttClient!.publish(topic, json, {})
|
||||||
|
}, 100)
|
||||||
await delay(100)
|
|
||||||
}
|
|
||||||
})().catch((e) => console.error(e))
|
})().catch((e) => console.error(e))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user