From 1ab0282101c6f37bdf9f3868e534d9220bc1a490 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Sun, 24 Oct 2021 09:12:29 -0400 Subject: [PATCH] Test button --- server/index.html | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/index.html b/server/index.html index 38631431..3a23585b 100644 --- a/server/index.html +++ b/server/index.html @@ -94,7 +94,7 @@ if (!topicEntry) { topicEntry = document.createElement('li'); topicEntry.id = `topic-${topic}`; - topicEntry.innerHTML = `${topic} `; + topicEntry.innerHTML = `${topic} `; topicsList.appendChild(topicEntry); } topicsHeader.style.display = ''; @@ -102,12 +102,12 @@ // Open event source let eventSource = new EventSource(`${topic}/sse`); eventSource.onopen = () => { - topicEntry.innerHTML = `${topic} `; + topicEntry.innerHTML = `${topic} `; delaySec = 0; // Reset on successful connection }; eventSource.onerror = (e) => { - const newDelaySec = (delaySec + 5 <= 30) ? delaySec + 5 : 30; - topicEntry.innerHTML = `${topic} (Reconnecting in ${newDelaySec}s ...) `; + const newDelaySec = (delaySec + 5 <= 15) ? delaySec + 5 : 15; + topicEntry.innerHTML = `${topic} (Reconnecting in ${newDelaySec}s ...) `; eventSource.close() subscribeInternal(topic, newDelaySec); }; @@ -130,6 +130,13 @@ } }; + const test = (topic) => { + fetch(`/${topic}`, { + method: 'PUT', + body: `This is a test notification for topic ${topic}!` + }) + }; + const showError = (msg) => { errorField.innerHTML = msg; topicField.disabled = true;