diff --git a/src/sse/SSEClient.js b/src/sse/SSEClient.js index 4deacce..e527dee 100644 --- a/src/sse/SSEClient.js +++ b/src/sse/SSEClient.js @@ -5,7 +5,6 @@ import { generateUUID } from "ant-design-vue/lib/vc-select/util"; let eventSource = null; let timer = null; -let lastHeartbeat = new Date().getTime(); const uuid = generateUUID(); const throttledConnectSSE = _.throttle((username) => { @@ -32,16 +31,11 @@ function connectToSSE(username) { eventSource.addEventListener('message', handleMessage); eventSource.addEventListener('error', handleError.bind(null, username)); - startHeartbeatCheck(username); } function handleMessage(event) { - if (event.data === 'h') { - lastHeartbeat = new Date().getTime(); - } else { - const msg = JSON.parse(event.data); - onMessage(msg); - } + const msg = JSON.parse(event.data); + onMessage(msg); } function handleError(username) { @@ -55,18 +49,6 @@ function clearExistingTimer() { } } -function startHeartbeatCheck(username) { - clearExistingTimer(); - timer = setInterval(() => { - if (eventSource.readyState === 1 && new Date().getTime() - lastHeartbeat > 5000) { - eventSource.close(); - } - if (eventSource.readyState === 2) { - throttledConnectSSE(username); - } - }, 3000); -} - function onMessage(msg) { const { url, body } = msg; const eventMapping = {