client fix

master
km0 2 years ago
parent 8de5337098
commit 3325c5405e

@ -18,22 +18,12 @@
).innerHTML += `<span style="color: ${color}">${text}</span><br>`; ).innerHTML += `<span style="color: ${color}">${text}</span><br>`;
}; };
console.log(location.protocol); const socket = new WebSocket(
console.log(
(location.protocol == "https:" ? "wss://" : "ws://") + (location.protocol == "https:" ? "wss://" : "ws://") +
location.host + location.host +
location.pathname.replace(new RegExp("\/" + "$"), "") + location.pathname.replace(new RegExp("\/" + "$"), "") +
"/echo/" "/echo/"
); );
const socket = new WebSocket(
location.protocol == "https:"
? "wss://"
: "ws://" +
location.host +
location.pathname.replace(new RegExp("\/" + "$"), "") +
"/echo/"
);
socket.addEventListener("message", (ev) => { socket.addEventListener("message", (ev) => {
log("<<< " + ev.data, "blue"); log("<<< " + ev.data, "blue");
}); });

Loading…
Cancel
Save