improved structure/functionality
[henge/kiak.git] / host.js
diff --git a/host.js b/host.js
new file mode 100644 (file)
index 0000000..2700506
--- /dev/null
+++ b/host.js
@@ -0,0 +1,17 @@
+const body = document.createElement('body')
+const root = document.createElement('div')
+document.title = "Strapp.io Host"
+if ("WebSocket" in window) {
+  const wsock = new WebSocket("wss://" + _strapp_host + ":" +  _strapp_port)
+  wsock.onopen = () => {
+    console.log("Strapped to wss://" + _strapp_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"))
+}
+body.appendChild(root)
+document.body = body