From 0ba5d25c7014dadedfdc4f6ee4d71c9b80f78d03 Mon Sep 17 00:00:00 2001 From: TheCodeTherapy Date: Fri, 1 Nov 2024 17:56:38 +0000 Subject: [PATCH] implements reset in one minute after last message --- .../server/mml-documents/agent.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/example/multi-user-3d-web-experience/server/mml-documents/agent.html b/example/multi-user-3d-web-experience/server/mml-documents/agent.html index 0bad0dc..3618af2 100644 --- a/example/multi-user-3d-web-experience/server/mml-documents/agent.html +++ b/example/multi-user-3d-web-experience/server/mml-documents/agent.html @@ -57,6 +57,7 @@ let queuedResponses = []; let responseInProgress = false; + let latestMessageTime = document.timeline.currentTime; class TextToCanvasImage { @@ -382,6 +383,15 @@ if (diff > 10) { textToCanvas.updateText(text); } + } else { + const diff = Math.ceil((document.timeline.currentTime - latestMessageTime) / 1000); + if (diff > 60) { + latestPromise = null; + queuedMessages = []; + queuedResponses = []; + responseInProgress = false; + textToCanvas.updateText(text); + } } } @@ -535,6 +545,7 @@ const chat = document.getElementById("chat"); chat.addEventListener("chat", (event) => { + latestMessageTime = document.timeline.currentTime; const { message, connectionId } = event.detail; submitMessage(message, connectionIdToUserId(connectionId)); });