Working ws

This commit is contained in:
2026-08-16 07:08:30 +02:00
parent d48cb52669
commit e7dd632633
+7 -2
View File
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react"; import { useEffect, useRef, useState } from "react";
import reactLogo from "./assets/react.svg"; import reactLogo from "./assets/react.svg";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import "./App.css"; import "./App.css";
@@ -8,7 +8,12 @@ function App() {
const [greetMsg, setGreetMsg] = useState(""); const [greetMsg, setGreetMsg] = useState("");
const [name, setName] = useState(""); const [name, setName] = useState("");
const initialized = useRef(false);
useEffect(() => { useEffect(() => {
if (initialized.current) return;
initialized.current = true;
(async () => { (async () => {
const ws = new EnclaveWebSocket("ws://localhost:3415"); const ws = new EnclaveWebSocket("ws://localhost:3415");
@@ -20,7 +25,7 @@ function App() {
hostname: "", hostname: "",
}); });
// console.log(await ws.read()); console.log(await ws.read());
})(); })();
}, []); }, []);