diff --git a/neopixel.js b/neopixel.js index 83693d1..f7717a7 100644 --- a/neopixel.js +++ b/neopixel.js @@ -311,7 +311,12 @@ function bin_to_json(bin) { let socket = undefined; function new_websocket() { - socket = new WebSocket("ws://localhost:9002"); + if (location.hostname == "") { + socket = new WebSocket("ws://localhost:9002"); + } else { + socket = new WebSocket(`ws://${location.hostname}:9002`); + } + socket.binaryType = "arraybuffer"; socket.onopen = function(e) { @@ -347,4 +352,4 @@ function new_websocket() { }; } -new_websocket(); \ No newline at end of file +new_websocket();