- const wsock = new WebSocket("wss://" + window.location.host + ":" + _strapp_port)
- wsock.onopen = () => {
- console.log("Strapped to wss://" + window.location.host + ":" + _strapp_port)
- }
- wsock.onmessage = (evt) => {
- console.log("Incoming connection from " + evt.data)
- console.log("TODO: Open a socket to this client")
- }
-} else {
- root.appendChild(document.createTextNode("Your browser does not support Strapp"))
+ document.addEventListener('DOMContentLoaded', (event) => {
+ const wsock = new WebSocket("wss://" + window.location.host + ":" + _strapp_port)
+ wsock.onopen = () => {
+ console.log("Strapped to wss://" + window.location.host + ":" + _strapp_port)
+ }
+ wsock.onmessage = (evt) => {
+ console.log("Incoming connection from " + evt.data)
+ console.log("TODO: Open a socket to this client")
+ wsock.send("Got " + evt.data)
+ clients.push({
+ ip: evt.data,
+ dataChannel: undefined
+ })
+ }
+ })
+}
+else {
+ document.addEventListener('DOMContentLoaded', () => {
+ document.body.innerHTML = 'Websockets not supported in your browser'
+ })