diff --git a/webui/index.html b/webui/index.html index 12343ad..f806fca 100644 --- a/webui/index.html +++ b/webui/index.html @@ -146,5 +146,6 @@ + diff --git a/webui/js/websocket.js b/webui/js/websocket.js new file mode 100644 index 0000000..f507cef --- /dev/null +++ b/webui/js/websocket.js @@ -0,0 +1,29 @@ +function websocketInit() { + let proto = "ws:" + + if (window.location.protocol == "https:") { + proto = "wss:" + } + + let wsUrl = proto + window.location.host + '/websocket' + + console.log(wsUrl) + + window.ws = new WebSocket(wsUrl) + + window.ws.addEventListener("open", () => { + console.log("socket opened!") + window.ws.send("Hi!") + }) + + window.ws.addEventListener("error", () => { + console.error("ws error") + }) + + window.ws.addEventListener("message", (msg) => { + console.log("ws msg", msg) + }) + +} + +websocketInit()