Skip to content

Commit

Permalink
fix(analysis) Emit to instructor on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
HagerDakroury committed Jul 22, 2021
1 parent aaa3858 commit 6926602
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions analysis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,26 @@ io.on("connection", (socket: any) => {
socket.on("disconnect", () => {
console.log("socket " + socket.id + " is disconnecting");
var socketId = socket.id;
if (socketId in sockets && student && meeting) {
if (socketId in sockets) {
var meeting = socketId.meeting;
var student = socketId.username;
var emotion = emotions[meeting][student];
instructors[meeting][emotion]--;
delete emotions[meeting][student];
console.log(
"socket: " +
socket.id +
"of user:+" +
student +
"disconnected from meeting:" +
meeting
);
if (student && meeting) {
var student = socketId.username;
var emotion = emotions[meeting][student];
instructors[meeting][emotion]--;
delete emotions[meeting][student];
console.log(
"socket: " +
socket.id +
"of user:+" +
student +
"disconnected from meeting:" +
meeting
);
io.to(meeting).emit(
"emotion update",
JSON.stringify(instructors[meeting])
);
}
}
io.to(meeting).emit("emotion update", JSON.stringify(instructors[meeting]));
});
Expand Down

0 comments on commit 6926602

Please sign in to comment.