diff --git a/cryptide_project/server/server.js b/cryptide_project/server/server.js index ddb6235..a7e6c5b 100644 --- a/cryptide_project/server/server.js +++ b/cryptide_project/server/server.js @@ -124,7 +124,7 @@ io.on('connection', (socket) => { socket.on("reset graph", (id) => { io.to(id).emit("reset graph") - }) + }) socket.on("end game", (winnerIndex, room) =>{ io.to(room).emit("end game", winnerIndex) diff --git a/cryptide_project/src/AdressConfig.ts b/cryptide_project/src/AdressConfig.ts new file mode 100644 index 0000000..b46e98b --- /dev/null +++ b/cryptide_project/src/AdressConfig.ts @@ -0,0 +1,7 @@ +const ADRESSE_WEBSERVER = "http://localhost:3002" + +const ADRESSE_DBSERVER = "http://localhost:3003" + +const ADRESSE_WEBSITE = "" + +export {ADRESSE_DBSERVER, ADRESSE_WEBSERVER, ADRESSE_WEBSITE} \ No newline at end of file diff --git a/cryptide_project/src/Components/GraphContainer.tsx b/cryptide_project/src/Components/GraphContainer.tsx index 2781d13..8eb67c5 100644 --- a/cryptide_project/src/Components/GraphContainer.tsx +++ b/cryptide_project/src/Components/GraphContainer.tsx @@ -45,7 +45,6 @@ const MyGraphComponent: React.FC = ({onNodeClick, handleS let cptTour: number = 0 const {isLoggedIn, user} = useAuth() - console.log('isLoggedIn : ' + isLoggedIn); const { indices, indice, person, personNetwork, setNodeIdData, players, askedPersons, setActualPlayerIndexData, room, actualPlayerIndex, turnPlayerIndex, setTurnPlayerIndexData, setWinnerData } = useGame(); const params = new URLSearchParams(window.location.search); @@ -258,6 +257,12 @@ let cptTour: number = 0 setNetwork(network) + socket.on("reset graph", () => { + console.log("reset graph") + initialOptions.physics.enabled = true + network.setOptions(initialOptions) + }) + if (!solo){ socket.on("asked all", (id) =>{ const pers = personNetwork.getPersons().find((p) => p.getId() == id) @@ -279,11 +284,6 @@ let cptTour: number = 0 networkData.nodes.update({id: node.id, opacity: 1}) }); }) - - socket.on("reset graph", () => { - initialOptions.physics.enabled = true - network.setOptions(initialOptions) - }) socket.on("node checked",(id, works, askedIndex, newPlayerIndex, socketId) => { console.log(newPlayerIndex) @@ -457,7 +457,6 @@ let cptTour: number = 0 setPlayerTouched(-1) setWinnerData(players[winnerIndex]) - console.log('isLoggedIn : ' + isLoggedIn); if(isLoggedIn){ if(solo){ diff --git a/cryptide_project/src/SocketConfig.ts b/cryptide_project/src/SocketConfig.ts index 2fea1de..54015d8 100644 --- a/cryptide_project/src/SocketConfig.ts +++ b/cryptide_project/src/SocketConfig.ts @@ -1,6 +1,7 @@ import { io } from "socket.io-client"; +import {ADRESSE_WEBSERVER} from "./AdressConfig" -const socket = io("http://localhost:3002"); +const socket = io(ADRESSE_WEBSERVER); export {socket} \ No newline at end of file diff --git a/cryptide_project/src/services/AuthService.tsx b/cryptide_project/src/services/AuthService.tsx index e7b85e4..10a9b1a 100644 --- a/cryptide_project/src/services/AuthService.tsx +++ b/cryptide_project/src/services/AuthService.tsx @@ -1,4 +1,6 @@ import VerificationService from './VerificationService'; +import {ADRESSE_DBSERVER} from "../AdressConfig" + class AuthService{ // Méthode pour vérifier les données de connexion @@ -12,7 +14,7 @@ class AuthService{ static async signUp(data: any) { try { - const response = await fetch('http://localhost:3003/auth/signup', { + const response = await fetch(ADRESSE_DBSERVER + '/auth/signup', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -36,7 +38,7 @@ class AuthService{ static async signIn(data: any) { try { - const response = await fetch('http://localhost:3003/auth/signin', { + const response = await fetch(ADRESSE_DBSERVER + '/auth/signin', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -61,7 +63,7 @@ class AuthService{ static async logout() { try { - const response = await fetch('http://localhost:3003/auth/logout', { + const response = await fetch(ADRESSE_DBSERVER + '/auth/logout', { method: 'DELETE', headers: { 'Content-Type': 'application/json', diff --git a/cryptide_project/src/services/SessionService.tsx b/cryptide_project/src/services/SessionService.tsx index 3fcb228..46340ab 100644 --- a/cryptide_project/src/services/SessionService.tsx +++ b/cryptide_project/src/services/SessionService.tsx @@ -1,7 +1,9 @@ +import {ADRESSE_DBSERVER} from "../AdressConfig" + class SessionService { static async getSession() { try { - const response = await fetch('http://localhost:3003/session', { + const response = await fetch(ADRESSE_DBSERVER + '/session', { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/cryptide_project/startServers.sh b/cryptide_project/startServers.sh index f340c6e..5b070e4 100755 --- a/cryptide_project/startServers.sh +++ b/cryptide_project/startServers.sh @@ -2,4 +2,16 @@ node server/server.js & -node src/server/server.js & \ No newline at end of file +node src/server/server.js + +if lsof -Pi :3002 -sTCP:LISTEN -t >/dev/null; then + # Tuer le processus associé au port + pid=$(lsof -Pi :3002 -sTCP:LISTEN -t) + kill -9 $pid +fi + +if lsof -Pi :3003 -sTCP:LISTEN -t >/dev/null; then + # Tuer le processus associé au port + pid=$(lsof -Pi :3003 -sTCP:LISTEN -t) + kill -9 $pid +fi \ No newline at end of file