From b924991afd38c89d1dfbfaa288ca9906128bb267 Mon Sep 17 00:00:00 2001 From: Domingo Dirutigliano Date: Sun, 6 Jul 2025 17:42:59 +0200 Subject: [PATCH 1/3] fix websocket connection --- frontend/src/App.tsx | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d346485..12b4260 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -21,7 +21,25 @@ function App() { const [reqError, setReqError] = useState() const [error, setError] = useState() const [loadinBtn, setLoadingBtn] = useState(false); - + const queryClient = useQueryClient() + + useEffect(()=>{ + socketio.auth = { token: localStorage.getItem("access_token") } + socketio.connect() + getStatus() + socketio.on("update", (data) => { + queryClient.invalidateQueries({ queryKey: data }) + }) + socketio.on("connect_error", (err) => { + errorNotify("Socket.Io connection failed! ",`Error message: [${err.message}]`) + getStatus() + }); + return () => { + socketio.off("update") + socketio.off("connect_error") + socketio.disconnect() + } +},[]) const getStatus = () =>{ getstatus().then( res =>{ @@ -140,26 +158,6 @@ function App() { const PageRouting = ({ getStatus }:{ getStatus:()=>void }) => { - const queryClient = useQueryClient() - - useEffect(()=>{ - socketio.auth = { token: localStorage.getItem("access_token") } - socketio.connect() - getStatus() - socketio.on("update", (data) => { - queryClient.invalidateQueries({ queryKey: data }) - }) - socketio.on("connect_error", (err) => { - errorNotify("Socket.Io connection failed! ",`Error message: [${err.message}]`) - getStatus() - }); - return () => { - socketio.off("update") - socketio.off("connect_error") - socketio.disconnect() - } -},[]) - return }> } > From d557b87cb5a9d48bdf065ddb28e71079af02f827 Mon Sep 17 00:00:00 2001 From: Domingo Dirutigliano Date: Mon, 14 Jul 2025 16:32:06 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ba40e22..7e2759d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Heres a brief description about the firegex structure: - [Frontend (React)](frontend/README.md) - [Backend (FastAPI + C++)](backend/README.md) +Some more specific information about how firegex works, and in particular how the nfproxy module works, are available here (in italian only): https://github.com/domysh/engineering-thesis + ![Firegex Working Scheme](docs/FiregexInternals.png) ### Main Points of Firegex From fc1e249351e2d785d3f5e0b35f2d46abdec56b2d Mon Sep 17 00:00:00 2001 From: Domingo Dirutigliano Date: Mon, 14 Jul 2025 16:37:23 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e2759d..8137997 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Heres a brief description about the firegex structure: - [Frontend (React)](frontend/README.md) - [Backend (FastAPI + C++)](backend/README.md) -Some more specific information about how firegex works, and in particular how the nfproxy module works, are available here (in italian only): https://github.com/domysh/engineering-thesis +More specific information about how Firegex works, and in particular about the nfproxy module, are available here (in italian only): [https://github.com/domysh/engineering-thesis](https://github.com/domysh/engineering-thesis) (PDF in the release attachments) ![Firegex Working Scheme](docs/FiregexInternals.png)