Epoxy Transport setup and working (mostly0
This commit is contained in:
parent
fd4c4f6fcb
commit
af88c5475b
3 changed files with 13 additions and 6 deletions
|
|
@ -16,7 +16,6 @@
|
|||
scope: "/~/"
|
||||
});
|
||||
});
|
||||
console.log("Service Worker Registered");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { useState, useEffect } from "preact/hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { changeTransport } from "../../util/transports";
|
||||
import { ToastContainer, toast } from "react-toastify";
|
||||
|
||||
interface WispInputProps {
|
||||
|
|
@ -17,10 +18,15 @@ function WispInput(props: WispInputProps) {
|
|||
} else if (finalUrl.startsWith("https://")) {
|
||||
finalUrl = finalUrl.replace("https://", "wss://");
|
||||
}
|
||||
else if (finalUrl === "" || finalUrl === null || finalUrl === undefined) {
|
||||
finalUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
}
|
||||
return finalUrl;
|
||||
}
|
||||
function handleChange() {
|
||||
const url = validateUrl((document.getElementById("input") as HTMLInputElement).value);
|
||||
const url = validateUrl((document.getElementById("wispinput") as HTMLInputElement).value);
|
||||
localStorage.setItem("wispUrl", url);
|
||||
changeTransport(localStorage.getItem("transport") || "epoxy", url);
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
|
|
@ -35,7 +41,7 @@ function WispInput(props: WispInputProps) {
|
|||
handleChange();
|
||||
}
|
||||
}}
|
||||
id="input"
|
||||
id="wispinput"
|
||||
className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl text-input-text"
|
||||
/>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ declare global {
|
|||
p: any;
|
||||
}
|
||||
}
|
||||
|
||||
function changeTransport(transport: string, wispUrl: string) {
|
||||
switch (transport) {
|
||||
case "epoxy":
|
||||
|
|
@ -20,7 +21,8 @@ function changeTransport(transport: string, wispUrl: string) {
|
|||
}
|
||||
}
|
||||
|
||||
//registerRemoteListener(navigator.serviceWorker.controller!);
|
||||
//const p = changeTransport("epoxy", "ws://localhost:5173/wisp/");
|
||||
//window.p = p;
|
||||
const wispUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
||||
registerRemoteListener(navigator.serviceWorker.controller!);
|
||||
changeTransport(localStorage.getItem("transport") || "epoxy", localStorage.getItem("wispUrl") || wispUrl);
|
||||
|
||||
export { changeTransport };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue