created another socket connection for different user

Signed-off-by: heyhiru <hirentimbadiya74@gmail.com>
Este commit está contenido en:
heyhiru
2023-11-11 16:23:14 +05:30
padre e3c2e0ebb8
commit 2def350a4f
Se han modificado 2 ficheros con 22 adiciones y 4 borrados

Ver fichero

@@ -1,6 +1,21 @@
import React from 'react'
import { useSocket } from '@/context/SocketProvider';
import React, { useCallback, useEffect } from 'react'
const RoomPage = () => {
const socket = useSocket();
const handleUserJoined = useCallback(({ email, id }) => {
console.log(`Email ${email} joined the room!`);
}, [])
useEffect(() => {
socket.on("user:joined", handleUserJoined);
return () => {
socket.off("user:joined", handleUserJoined);
};
}, [socket, handleUserJoined]);
return (
<h1>RoomPage</h1>
)