From 8befaa53c2b0f22002cd8a68a61b6305b542baf7 Mon Sep 17 00:00:00 2001 From: Thomas CHAZOT Date: Tue, 12 Dec 2023 10:36:39 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'cryptide=5Fproject?= =?UTF-8?q?/src/Components/GraphContainer.tsx'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cryptide_project/src/Components/GraphContainer.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 7592579..64682ad 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -22,7 +22,7 @@ import html2canvas from 'html2canvas'; import jsPDF from 'jspdf'; import {basePath} from "../AdressSetup" -import { io } from "socket.io-client"; +import { socketIOClient } from "socket.io-client"; import { ADRESSE_WEBSERVER } from "../AdressSetup"; interface MyGraphComponentProps { @@ -131,13 +131,23 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS }, []); useEffect(() => { + + const socket2 = socketIOClient(ADRESSE_WEBSERVER); // Démarrez le timer au montage du composant const intervalId = setInterval(() => { - const socket2 = io(ADRESSE_WEBSERVER); console.log(socket2.id) }, 500); + socket2.on('connect', () => { + console.log('Connecté au serveur Socket.IO'); + }); + + // Gestion de l'événement de déconnexion + socket2.on('disconnect', () => { + console.log('Déconnecté du serveur Socket.IO'); + }); + // Nettoyez l'intervalle lorsque le composant est démonté return () => clearInterval(intervalId); }, []);