From 61927e0260d5b8af77ee2076b8eab31a23d7dd70 Mon Sep 17 00:00:00 2001
From: XOSG <2195868682@qq.com>
Date: Fri, 19 Jan 2024 14:43:06 +0800
Subject: [PATCH] 1
---
signal.html | 79 ++++++++++++++++++++++++++---------------------------
signal.js | 64 +++++++++++++++++++++++--------------------
signal.json | 2 +-
3 files changed, 75 insertions(+), 70 deletions(-)
diff --git a/signal.html b/signal.html
index c7fd16c..fe26c37 100644
--- a/signal.html
+++ b/signal.html
@@ -355,7 +355,7 @@
>
@@ -627,31 +627,6 @@
});
}
- //渲染页面主内容
- const actions = {
- "#config": async () => {
- $("main").innerHTML = config;
- await renderConfigForm();
- $("#auth").addEventListener("focus", () => toggleAuthInfo(event));
- $("#auth").addEventListener("blur", () => toggleAuthInfo(event));
- $("#http-auth").addEventListener("click", () => toggleAuthInput());
- $("form").addEventListener("change", () => submitConfig(event));
- },
- "#peer-stream": () => {
- $("main").innerHTML = runningServer;
- ps.addEventListener("playing", aggregateStats, {
- once: true,
- });
- ps.addEventListener("message", (e) => {});
- window.addEventListener("hashchange", (e) => clearTimeout(ps.timeout), { once: true });
- },
- "#process": () => {
- $("main").innerHTML = process;
- getProcess();
- },
- "": () => {},
- };
-
//开关http验证
const toggleAuthInput = () => {
$("#auth-input").style.display = $("#http-auth").checked ? "flex" : "none";
@@ -925,7 +900,8 @@
};
const getProcess = () => {
- const ws = new WebSocket(`ws://${location.host}/${navigator.platform}`, `exec-ue`);
+ let ws = `ws://${location.host}/${navigator.platform}/${navigator.vendor}`;
+ ws = new WebSocket(ws, `exec-ue`);
ws.onopen = function () {
console.info("✅", ws);
window.addEventListener("hashchange", () => ws.close(), { once: true });
@@ -936,13 +912,13 @@
logs = logs
.map(
(a) => `
-
- ${a.type} |
- ${a.address} |
- ${a.PORT} |
- ${a.path} |
- 断开 |
-
`
+
+ ${a.type} |
+ ${a.address} |
+ ${a.PORT} |
+ ${a.path} |
+ 断开 |
+
`
)
.join("");
$("table tbody").innerHTML = logs;
@@ -958,7 +934,7 @@
const process = event.target.parentElement.children;
const PORT = process[2].innerText;
let eval = {
- "signal.js": "process.exit(0)",
+ "signal.js": "setTimeout(()=>process.exit(0),1),''",
"Unreal Engine": `killUE(${PORT})`,
" Peer Stream": `killPlayer(${PORT})`,
};
@@ -975,9 +951,7 @@
if (!r.ok) throw r.headers.get("error");
handleUpdateSuccess($(`#process`));
})
- .catch((err) => {
- alert(err);
- });
+ .catch((error) => alert(error));
}
}
@@ -1051,8 +1025,33 @@
};
// 页面加载和变化
- window.onload = window.onhashchange = () => {
- actions[location.hash].call();
+ window.onload = window.onhashchange = async () => {
+ switch (location.hash) {
+ case "#config": {
+ $("main").innerHTML = config;
+ await renderConfigForm();
+ $("#auth").addEventListener("focus", () => toggleAuthInfo(event));
+ $("#auth").addEventListener("blur", () => toggleAuthInfo(event));
+ $("#http-auth").addEventListener("click", () => toggleAuthInput());
+ $("form").addEventListener("change", () => submitConfig(event));
+ break;
+ }
+ case "#peer-stream": {
+ $("main").innerHTML = runningServer;
+ ps.addEventListener("playing", aggregateStats, {
+ once: true,
+ });
+ window.addEventListener("hashchange", (e) => clearTimeout(ps.timeout), { once: true });
+ break;
+ }
+ case "#process": {
+ $("main").innerHTML = process;
+ getProcess();
+ break;
+ }
+ default: {
+ }
+ }
};