mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-01-10 17:22:13 +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');
|
ui.waitMessage(document.getElementById('divContainer')).classList.add('socket-wait');
|
||||||
let host = window.location.protocol === 'file:' ? hst : window.location.hostname;
|
let host = window.location.protocol === 'file:' ? hst : window.location.hostname;
|
||||||
try {
|
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) => {
|
socket.onmessage = (evt) => {
|
||||||
if (evt.data.startsWith('42')) {
|
if (evt.data.startsWith('42')) {
|
||||||
let ndx = evt.data.indexOf(',');
|
let ndx = evt.data.indexOf(',');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue