diff --git a/index.html b/index.html index d189f28..7243eae 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - C&J + CnJ diff --git a/script.js b/script.js index 69a4691..fc3abde 100644 --- a/script.js +++ b/script.js @@ -41,9 +41,20 @@ window.onload = () => { } connectWS() + connectSSE() } +function connectSSE() { + var source = new EventSource("http://127.0.0.1:3005/sse") + source.onmessage = (e) => { + console.log(e.data) + + let obj = JSON.parse(e.data) + + console.log(obj.Body) + } +} function connectWS() { ws = new WebSocket(wsAddress + wsPort) @@ -58,6 +69,7 @@ function connectWS() { let data = JSON.parse(msg.data) + // Only used here to test whether messages can be sent between the servers if (data["Cmd"] == 99999) { document.getElementById("userid").innerHTML = data["Body"] }