mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-01-10 01:02:12 +01:00
Refactor WebSocket connection to support HTTPS
This commit is contained in:
parent
eb75868adb
commit
16e47163ec
1 changed files with 3 additions and 1 deletions
|
|
@ -469,7 +469,9 @@ async function initSockets() {
|
|||
ui.waitMessage(document.getElementById('divContainer')).classList.add('socket-wait');
|
||||
let host = window.location.protocol === 'file:' ? hst : window.location.hostname;
|
||||
try {
|
||||
socket = new WebSocket(`ws://${host}:8080/`);
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const port = window.location.protocol === 'https:' ? '' : ':8080';
|
||||
socket = new WebSocket(`${protocol}//${host}${port}/`);
|
||||
socket.onmessage = (evt) => {
|
||||
if (evt.data.startsWith('42')) {
|
||||
let ndx = evt.data.indexOf(',');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue