mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
correction user-joined
This commit is contained in:
parent
5c736f4ca0
commit
c9b76df2cd
1 changed files with 14 additions and 1 deletions
|
|
@ -189,6 +189,18 @@ const ManageRoom: React.FC = () => {
|
||||||
setConnectingError(errorMessage);
|
setConnectingError(errorMessage);
|
||||||
console.error('Erreur création salle:', errorMessage);
|
console.error('Erreur création salle:', errorMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('user-joined', (student: StudentType) => {
|
||||||
|
console.log(`Student joined: name = ${student.name}, id = ${student.id}`);
|
||||||
|
|
||||||
|
setStudents((prevStudents) => [...prevStudents, student]);
|
||||||
|
|
||||||
|
if (quizMode === 'teacher') {
|
||||||
|
webSocketService.nextQuestion(roomName, currentQuestion);
|
||||||
|
} else if (quizMode === 'student') {
|
||||||
|
webSocketService.launchStudentModeQuiz(roomName, quizQuestions);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (rooms.length === 0) {
|
if (rooms.length === 0) {
|
||||||
|
|
@ -208,7 +220,7 @@ const ManageRoom: React.FC = () => {
|
||||||
handleRoomCreation(newSocket, targetRoom.title);
|
handleRoomCreation(newSocket, targetRoom.title);
|
||||||
setSocket(newSocket);
|
setSocket(newSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket?.on('connect_error', (error) => {
|
socket?.on('connect_error', (error) => {
|
||||||
setConnectingError('Erreur de connexion au serveur...');
|
setConnectingError('Erreur de connexion au serveur...');
|
||||||
console.error('Connection error:', error);
|
console.error('Connection error:', error);
|
||||||
|
|
@ -221,6 +233,7 @@ const ManageRoom: React.FC = () => {
|
||||||
console.log(`Listening for user-joined in room ${roomName}`);
|
console.log(`Listening for user-joined in room ${roomName}`);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
socket.on('user-joined', (_student: StudentType) => {
|
socket.on('user-joined', (_student: StudentType) => {
|
||||||
|
console.log("📢 Nouvel étudiant ajouté:", _student);
|
||||||
if (quizMode === 'teacher') {
|
if (quizMode === 'teacher') {
|
||||||
webSocketService.nextQuestion(roomName, currentQuestion);
|
webSocketService.nextQuestion(roomName, currentQuestion);
|
||||||
} else if (quizMode === 'student') {
|
} else if (quizMode === 'student') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue