host
[henge/kiak.git] / host.js
1 document.title = "Strapp.io Host"
2 const clients = []
3 if ("WebSocket" in window) {
4 const wsock = new WebSocket(`${_strapp_protocol}://${window.location.hostname}:${_strapp_port}`)
5 wsock.onopen = () => {
6 console.log(`Strapped to ${_strapp_protocol}://${window.location.hostname}:${_strapp_port}`)
7 }
8 wsock.onmessage = (evt) => {
9 console.log("Incoming connection from " + evt.data)
10 console.log("TODO: Open a socket to this client")
11 wsock.send("Got " + evt.data)
12 clients.push({
13 ip: evt.data,
14 dataChannel: undefined
15 })
16 }
17 }
18 else {
19 document.addEventListener('DOMContentLoaded', () => {
20 document.body.innerHTML = 'Websockets not supported in your browser'
21 })
22 }