- // TODO: Prevent socket connection (just ignore) if student already connected
-// io.of('/').in(aid).clients((error, clients) => {
-// if (error)
-// throw error;
-// if (clients.some( c => { return c. .. == number; }))
-// // Problem: we just have a list of socket IDs (not handshakes)
-// });
- // TODO: next is conditional to "student not already taking the exam"
- socket.on(message.allAnswers, () => { //got all answers from teacher
- socket.emit(message.allAnswers, m);
+ EvaluationModel.newConnection(ObjectId(aid), number);
+ socket.broadcast.to(aid + "_teacher").emit(message.studentConnect, {number: number});
+ socket.join(aid + "_student");
+ socket.on(message.newAnswer, m => { //got answer from student client
+ socket.broadcast.to(aid + "_teacher").emit(message.newAnswer, m);
+ });
+ socket.on(message.studentBlur, m => {
+ socket.broadcast.to(aid + "_teacher").emit(message.studentBlur, m);
+ });
+ socket.on(message.studentFocus, m => {
+ socket.broadcast.to(aid + "_teacher").emit(message.studentFocus, m);
+ });
+ socket.on(message.studentResize, m => {
+ socket.broadcast.to(aid + "_teacher").emit(message.studentResize, m);
+ });
+ socket.on(message.studentFullscreen, m => {
+ socket.broadcast.to(aid + "_teacher").emit(message.studentFullscreen, m);