From 3adcf3ed333732942cdec18944e4aaeadd1c5b17 Mon Sep 17 00:00:00 2001 From: ken Date: Wed, 28 Jun 2017 00:18:11 -0700 Subject: [PATCH] host --- host.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/host.js b/host.js index 95d3cc6..45ea63f 100644 --- a/host.js +++ b/host.js @@ -1,21 +1,19 @@ document.title = "Strapp.io Host" const clients = [] if ("WebSocket" in window) { - document.addEventListener('DOMContentLoaded', (event) => { - const wsock = new WebSocket(`${_strapp_protocol}://${window.location.hostname}:${_strapp_port}`) - wsock.onopen = () => { - console.log(`Strapped to ${_strapp_protocol}://${window.location.hostname}:${_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 - }) - } - }) + const wsock = new WebSocket(`${_strapp_protocol}://${window.location.hostname}:${_strapp_port}`) + wsock.onopen = () => { + console.log(`Strapped to ${_strapp_protocol}://${window.location.hostname}:${_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', () => { -- 2.18.0