feat: 信令跟踪保活续期

This commit is contained in:
TsMask
2024-10-15 15:14:38 +08:00
parent 6e11d2b16a
commit d77c4e43d4

View File

@@ -18,6 +18,7 @@ import {
packetStart,
packetStop,
packetFilter,
packetKeep,
} from '@/api/trace/packet';
const ws = new WS();
const { t } = useI18n();
@@ -29,6 +30,8 @@ type StateType = {
devices: { id: string; label: string; children: any[] }[];
/**初始化 */
initialized: boolean;
/**保活调度器 */
keepTimer: any;
/**任务 */
task: {
taskNo: string;
@@ -64,6 +67,7 @@ type StateType = {
const state = reactive<StateType>({
devices: [],
initialized: false,
keepTimer: null,
task: {
taskNo: 'laYlTbq',
device: '192.168.5.58',
@@ -274,6 +278,9 @@ function wsMessage(res: Record<string, any>) {
// 建联时发送请求
if (!requestId && data.clientId) {
state.initialized = true;
state.keepTimer = setInterval(() => {
packetKeep(state.task.taskNo, 120);
}, 90 * 1000);
return;
}
@@ -320,7 +327,9 @@ onMounted(() => {
});
onBeforeUnmount(() => {
ws.close();
clearInterval(state.keepTimer);
state.keepTimer = null;
if (ws.state() === WebSocket.OPEN) ws.close();
});
</script>