Skip to content

Commit

Permalink
Merge pull request #42 from jennydo/noti
Browse files Browse the repository at this point in the history
Socket.io: Notification
  • Loading branch information
Euclid0192 authored Jun 19, 2024
2 parents 2db4830 + 6a177b2 commit fe06b03
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mongoose
socket.on("setup", (userData) => {
socket.join(userData._id);
socket.emit("connected");
console.log(userData.username + " joined Room: " + userData._id);
});

socket.on("join chat", (room) => {
Expand All @@ -113,10 +114,11 @@ mongoose

if (!chat.users) return console.log("chat.users not defined");

// socket.in(chat._id).emit("message received", newMessageRecieved);

chat.users.forEach((user) => {
if (user._id == newMessageRecieved.sender._id) return;

socket.in(user._id).emit("message recieved", newMessageRecieved);
socket.in(user._id).emit("message received", newMessageRecieved);
});
});

Expand Down

0 comments on commit fe06b03

Please sign in to comment.