Skip to content

Commit

Permalink
broadcast bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
BhanuArora123 committed Oct 26, 2022
1 parent 371de06 commit 547738c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ mongoose.connect(process.env.MONGO_URI)
// socket join room event
socket.on("join_room",(roomId,userName) => {
socket.join(roomId);
socket.to(roomId).broadcast({
socket.to(roomId).broadcast.emit({
message:"a new user join the room!",
userName
})
});

socket.on("leave_room",(roomId,userName) => {
socket.leave(roomId);
socket.to(roomId).broadcast({
socket.to(roomId).broadcast.emit({
message:`${userName} left the room`,
userName
})
Expand All @@ -67,7 +67,7 @@ mongoose.connect(process.env.MONGO_URI)
let { roomId,userId } = data;
let userData = await getUserData(userId);
markProblemAsSolved(data);
socket.to(roomId).broadcast({
socket.to(roomId).broadcast.emit({
message:`${userData.userName} solved a problem!`,
userName:userData.userName
})
Expand Down

0 comments on commit 547738c

Please sign in to comment.