new: [front:socketConnection] Added last-keep alive message

This commit is contained in:
Sami Mokaddem 2024-07-04 11:30:44 +02:00
parent b79152a6e5
commit 8774d70759

View file

@ -1,9 +1,17 @@
<script setup> <script setup>
import { computed } from "vue" import { ref, onMounted } from "vue"
import { socketConnected, zmqLastTime } from "@/socket"; import { socketConnected, zmqLastTime } from "@/socket";
const zmqLastTimeSecond = computed(() => { const zmqLastTimeSecond = ref(0)
return parseInt(((new Date()).getTime() - zmqLastTime.value * 1000) / 1000)
function refreshLastTime() {
zmqLastTimeSecond.value = parseInt(((new Date()).getTime() - zmqLastTime.value * 1000) / 1000)
}
onMounted(() => {
setInterval(() => {
refreshLastTime()
}, 1000)
}) })
</script> </script>
@ -27,7 +35,7 @@
online online
</template> </template>
<template v-else> <template v-else>
{{ zmqLastTimeSecond }}s Last keep-alive: {{ zmqLastTimeSecond }}s ago
</template> </template>
</span> </span>
</span> </span>