added data sharing between session and socket

This commit is contained in:
Wenszel
2022-05-28 22:54:23 +02:00
parent f24bbf2daf
commit ecc319b529
4 changed files with 92 additions and 107 deletions
+6 -10
View File
@@ -19,16 +19,12 @@ function App() {
const [redirect, setRedirect] = useState();
useEffect(() => {
const socket = io("http://localhost:5000");
socket.on("connect", () => console.log(socket.id));
axios
.get("/player", {
withCredentials: true,
})
.then((response) => {
setPlayerData(response.data);
response.data.roomId != null ? setRedirect(true) : setRedirect(false);
});
const socket = io("http://localhost:5000", { withCredentials: true });
socket.on("client data", (data) => {
data = JSON.parse(data);
setPlayerData(data);
data.roomId != null ? setRedirect(true) : setRedirect(false);
});
}, []);
const handleExit = (e) => {